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

Support MCP Resource Templates / Dynamic Resources #4617

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LLukas22
Copy link
Contributor

Description

Enable support for dynamic MCP resources, such as echo://{message}.

Ideally, this functionality should be expanded to accommodate resources with multiple inputs. However, this serves as an initial draft.

Checklist

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

Screenshots

MCPTemplates.mp4

Testing instructions

Create MCP test server, e.g.:

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("Echo")

@mcp.resource("echo://test", name="test")
def test_resource() -> str:
    """Echo a message as a resource"""
    return "Test"

@mcp.resource("echo://{message}", name="echo")
def echo_resource(message: str) -> str:
    """Echo a message as a resource"""
    return f"Resource echo: {message}"


@mcp.resource("echo://{input}", name="other_template_resource")
def echo_resource(input: str) -> str:
    """other template resource"""
    return f"Your input: {input}"


if __name__ == "__main__":
    print("Starting Echo Server ...")
    mcp.run()

Add to config e.g.:

mcpServers:
  - name: MCPEcho
    command: uv
    args:
      - --directory=[PATH_TO_SERVER]
      - run
      - server.py

Copy link

netlify bot commented Mar 12, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit c044909
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67d1977b6af57b00089850d8

@sestinj sestinj requested a review from RomneyDa March 16, 2025 20:29
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