Skip to content

feat(virtual-mcp): auto-adopt MCP server prompt as agent instructions#3164

Open
vibegui wants to merge 1 commit intomainfrom
feat/auto-adopt-mcp-prompt-as-instructions
Open

feat(virtual-mcp): auto-adopt MCP server prompt as agent instructions#3164
vibegui wants to merge 1 commit intomainfrom
feat/auto-adopt-mcp-prompt-as-instructions

Conversation

@vibegui
Copy link
Copy Markdown
Contributor

@vibegui vibegui commented Apr 23, 2026

Summary

  • When a virtual MCP agent has no metadata.instructions set, the server now automatically resolves the system prompt from the connected MCP server's named prompts
  • Resolution order: (1) metadata.instructions if explicitly set, (2) prompt matching agent title slug, (3) first available prompt, (4) undefined
  • All existing behavior preserved — metadata.instructions always wins

Motivation

MCP servers should own their system prompt in code (e.g. prompt.md). Previously, there was no bridge between a server's declared prompt and the studio's metadata.instructions field — requiring manual copy-paste that was never done. This change closes that gap automatically.

Test plan

  • Agent with metadata.instructions set → still uses it, no change
  • Agent with no metadata.instructions, connected MCP has a prompt named "ceo" (matches title "CEO Agent") → uses that prompt as instructions
  • Agent with no metadata.instructions, connected MCP has prompts but none match → uses first available
  • Agent with no metadata.instructions, connected MCP has no prompts → falls through gracefully, undefined
  • Connected MCP listPrompts throws → caught, falls through gracefully

🤖 Generated with Claude Code


Summary by cubic

Automatically uses the connected MCP server’s named prompt as the agent’s system instructions when a virtual MCP agent has no metadata.instructions. This removes manual copy-paste and keeps agents aligned with server prompt.md.

  • New Features
    • Resolution order: metadata.instructions > prompt matching agent title slug (lowercased, alphanumeric) > first available prompt > undefined.
    • Handles errors and empty prompts gracefully; falls back to no instructions.
    • Passes the resolved instructions to createServerFromClient; existing behavior unchanged.

Written for commit f447f7b. Summary will update on new commits.

When a virtual MCP agent has no metadata.instructions set, automatically
resolve the system prompt from the connected MCP server's named prompts.

Resolution order:
1. metadata.instructions (explicit, wins always)
2. Prompt whose name matches the agent title slug (e.g. "CEO Agent" → "ceo")
3. First available prompt from connected MCPs
4. undefined (no instructions)

This allows MCP servers to own their system prompt in code (prompt.md)
without requiring manual copy-paste into the studio database.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Copy Markdown
Contributor

Release Options

Suggested: Minor (2.273.0) — based on feat: prefix

React with an emoji to override the release type:

Reaction Type Next Version
👍 Prerelease 2.272.3-alpha.1
🎉 Patch 2.272.3
❤️ Minor 2.273.0
🚀 Major 3.0.0

Current version: 2.272.2

Note: If multiple reactions exist, the smallest bump wins. If no reactions, the suggested bump is used (default: patch).

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