Skip to content

Add MCP skill discovery and on-demand loading#6

Merged
RaghavSood merged 2 commits intofeature/find-token-supportfrom
feature/mcp-skills
Feb 24, 2026
Merged

Add MCP skill discovery and on-demand loading#6
RaghavSood merged 2 commits intofeature/find-token-supportfrom
feature/mcp-skills

Conversation

@RaghavSood
Copy link
Collaborator

Summary

  • Integrates MCP resources protocol (resources/list, resources/read) to discover skill guides from the MCP server
  • Skills are listed in the system prompt so the LLM knows what's available, but content is only loaded on-demand via the new get_skill tool
  • Skill list and content are cached with the same TTL as MCP tools, with background refresh on stale cache

Stacked on #3#2.

Architecture

Startup:
  main.go → mcpClient.ListSkills() → cache skill metadata

Per-request (ProcessMessage):
  System prompt += SkillSummary()     → "## Available Skills\n- **dca-setup**: ...\n- **swap-tokens**: ..."
  Tools list  += GetSkillTool         → only if skills exist

On-demand (decision loop):
  LLM calls get_skill(slug) → executor → mcpClient.ReadSkill(slug)
                                           ↓
                                       resources/read → "skills/{slug}.md"
                                           ↓
                                       markdown content returned to LLM as tool result

Key design decision: The skill list (names + descriptions) is always in the system prompt so the LLM can decide relevance. The skill content (full markdown) is only loaded when the LLM calls get_skill. This keeps the context window lean as the skill library grows.

Changes

File Change
internal/mcp/client.go Add MCP resource types, skillCache, ListSkills, ReadSkill, SkillSummary
internal/service/agent/agent.go Extend MCPToolProvider interface, inject skill summary into prompt, register GetSkillTool
internal/service/agent/tools.go Add GetSkillTool definition
internal/service/agent/executor.go Add get_skill dispatch + execGetSkill handler
cmd/server/main.go Pre-warm skill cache at startup

MCP Protocol Details

Skill discovery uses standard MCP resources protocol:

  • resources/list → filter for URIs matching skills/*.md
  • resources/read with URI skills/{slug}.md → skill markdown content

Caching:

  • Skill list: TTL-based cache (same as tools), background refresh when stale
  • Skill content: cached in sync.Map for process lifetime (docs change with deployments)

Test plan

  • Build passes: go build ./...
  • Startup with MCP server that has skills: verify mcp skills loaded log
  • Startup with MCP server without resources support: verify graceful degradation
  • Startup without MCP: verify no skill-related logs or errors
  • Send message that matches a skill: verify LLM calls get_skill and uses the content
  • Send message that doesn't match any skill: verify LLM does NOT call get_skill
  • Verify skill content is cached (second load is instant, no resources/read call)

🤖 Generated with Claude Code

@RaghavSood RaghavSood force-pushed the feature/find-token-support branch from 3de125d to 5078c33 Compare February 24, 2026 04:31
RaghavSood and others added 2 commits February 24, 2026 12:48
Integrate MCP resources protocol (resources/list, resources/read) to
discover and load skill guides from the MCP server. Skills are markdown
documents at skills/{slug}.md that provide detailed workflow instructions.

The skill list is injected into the system prompt so the LLM knows what's
available, but skill content is only loaded on-demand via the new get_skill
tool when relevant to the user's request. This keeps the context window
lean as the skill library grows.

- MCP client: add ListSkills, ReadSkill, SkillSummary with TTL caching
- Agent: extend MCPToolProvider interface with skill methods
- Agent: inject skill summary into system prompt after tool descriptions
- Tools: add get_skill native tool (only registered when skills exist)
- Executor: add get_skill handler delegating to MCP ReadSkill
- Main: pre-warm skill cache at startup alongside tools

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The MCP server returns skill resources with URIs like
"skill://vultisig/evm-contract-call.md" but extractSkillSlug was
filtering for the "skills/" prefix, discarding all entries.

- extractSkillSlug now extracts the last path segment before .md,
  handling any URI scheme (skill://, skills/, etc.)
- ReadSkill now looks up the full URI from the skill cache instead
  of constructing it, so it works with any URI format

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@RaghavSood RaghavSood merged commit 1f54c42 into feature/find-token-support Feb 24, 2026
enriquesouza pushed a commit that referenced this pull request Feb 27, 2026
Add MCP skill discovery and on-demand loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant