Files
oikos/internal/mcp/server_test.go
dtoro 3823a82417 phase 4: hermes agent — MCP tools, activity logging, 'all' role, wiring fixes
- mcp/server.go: 7 new tools (get_signal_history, get_patterns, get_skills,
  request_execution, get_trend, get_event_timeline, get_agent_activity),
  agent_activity logging middleware on every tool call.
- phase3.go: QueryAgentActivity REST handler implemented (was stub).
  Fixed scan count mismatch in ListSkills/PatchSkill/ListSkillVersions
  (13 cols → 12 targets). Fixed AgentActivity cursor pagination
  (lexicographic → integer comparison). Fixed s.Slug → s.Name in log.
- cmd/oikos/main.go: 'all' role now runs api + scheduler + notifier in
  one process. Replaced nil SchedulerRunner/NotifierRunner with direct
  scheduler.RunnerForMain() / notifier.RunnerForMain() imports.
  Added runWithPool helper for standalone scheduler/notifier roles.
- internal/config/config.go: added HermesAgentID env var.
- internal/httpapi/server.go: pass HermesAgentID to MCP handler.
- docker-compose.yml: added scheduler and notifier services (dev profile).
- hermes/: config.yaml, SOUL.md, skills/homelab-ops/SKILL.md.
- Cleaned up: scheduler/init.go dead code, mcp/server.go pgx import guard.
2026-07-07 16:07:08 +02:00

43 lines
1.3 KiB
Go

package mcp
import (
"testing"
"github.com/google/uuid"
)
// TestNewServerRegistersTools verifies every tool registers with a valid
// input schema. The MCP SDK panics at AddTool if a tool omits its object
// input schema, so merely constructing the server exercises that contract —
// this test would have caught the "missing input schema" panic.
func TestNewServerRegistersTools(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Fatalf("newServer panicked (tool schema bug?): %v", r)
}
}()
// pool is only used inside tool handlers (invoked per-call), not at
// registration time, so a nil pool is safe for this construction test.
s := newServer(nil, uuid.Nil)
if s == nil {
t.Fatal("newServer returned nil")
}
}
func TestObjSchema(t *testing.T) {
s := objSchema(prop{"foo", "string", "a foo"}, prop{"n", "integer", "a number"})
if s.Type != "object" {
t.Errorf("schema type = %q, want object", s.Type)
}
if len(s.Properties) != 2 {
t.Fatalf("got %d properties, want 2", len(s.Properties))
}
if s.Properties["foo"].Type != "string" || s.Properties["n"].Type != "integer" {
t.Errorf("property types wrong: %+v", s.Properties)
}
// empty schema still valid (object with no properties)
if objSchema().Type != "object" {
t.Error("empty objSchema not an object")
}
}