Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model context protocol prompt fix and roots #4533

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

alexsmirnov
Copy link

Description

[ What changed? Feel free to be brief. ]
The fix updates prompt ( slash command ) obtained from MCP to properly include prompt context into model call.
Without it, all @... context resources stripped out from user message. The code based on /review and custom prompt command code. Noisy comments reflect my investigation into how it works. To confirm correctness, it also includes unit test that repeated all combinations that I collected from debug sessions.

The second change is support for MCP roots feature https://modelcontextprotocol.io/docs/concepts/roots.
Client reports workspace directories as response to request from server. I found it necessary to provide workspace specific resources and tools.
I do not dare to include my project https://github.com/alexsmirnov/mcp-server-continue as reference to documentation, it's too early stage. But it supports all features.

Checklist

  • [] The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Screenshots

[ For visual changes, include screenshots. ]

Testing instructions

with https://github.com/alexsmirnov/mcp-server-continue and uv https://github.com/astral-sh/uv
config.json:

{
"experimental": {
    "modelContextProtocolServers": [
      {
        "transport": {
          "type": "stdio",
          "command": "uv",
          "args": [
            "run",
            "--project",
            "<absolute path project folder>/mcp-server-continue",
            "mcps"
          ]
        }
      }
    ]
  }
}

slash command /echo with @some.file , or any other resource
[ For new or modified features, provide step-by-step testing instructions to validate the intended behavior of the change, including any relevant tests to run. ]

Copy link

netlify bot commented Mar 7, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit 868d1dc
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67d36b5531ae9c0008da89d0

@alexsmirnov alexsmirnov force-pushed the mcp-prompt-fix-and-roots branch from dbd232a to 868d1dc Compare March 13, 2025 23:33
@sestinj
Copy link
Contributor

sestinj commented Mar 16, 2025

@alexsmirnov I'm thinking that the cleaner way to solve this replacement problem would be by handling it in resolveInput.ts, which is where we replace context providers with their content. That way all of the logic would be centralized in one place

@sestinj sestinj self-requested a review March 16, 2025 20:30
@alexsmirnov
Copy link
Author

Hi @sestinj , this is that confused me at the first place, how other prompt providers handle resources. I copied functionality from review, and custom prompts. Can you give me directions how to use resolveInput.ts ? I'll take a look on my own by the way

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.

2 participants