这是indexloc提供的服务,不要输入任何密码
Skip to content

How to setup a dynamic Resource Template #12

@djshubs

Description

@djshubs

I have successfully created a regular/static resource template; however, I am having trouble developing a resource template that mirrors the structure and content of the TypeScript SDK repository on GitHub, specifically the README file’s “Resources” section.

LINK: https://github.com/modelcontextprotocol/typescript-sdk?tab=readme-ov-file#resources

// Dynamic resource with parameters
server.resource(
  "user-profile",
  new ResourceTemplate("users://{userId}/profile", { list: undefined }),
  async (uri, { userId }) => ({
    contents: [{
      uri: uri.href,
      text: `Profile data for user ${userId}`
    }]
  })
);

Any suggestions on how to mimic this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions