Skip to content

Impossible to instrument @modelcontextprotocol/sdk #187

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

Open
lforst opened this issue Apr 11, 2025 · 3 comments
Open

Impossible to instrument @modelcontextprotocol/sdk #187

lforst opened this issue Apr 11, 2025 · 3 comments
Assignees

Comments

@lforst
Copy link

lforst commented Apr 11, 2025

The @modelcontextprotocol/sdk package wants you to import stuff from "@modelcontextprotocol/sdk/server/mcp.js" like so:

import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";

This import resolves to node_modules/@modelcontextprotocol/dist/esm/sdk/server/mcp.js.

I cannot find a way to provide a module definition to new Hook() that will actually wrap the module.

It seems like we are always ending up in this branch

if (!baseDir.endsWith(specifiers.get(filename))) continue
and bailing the wrapping.

@AbhiPrasad
Copy link

@timfish I think we need to get rid of this condition - see #185

@timfish
Copy link
Contributor

timfish commented Apr 16, 2025

I've tried with the above line removed and we get a single test failure on this assertion. I don't fully understand this negative assertion!

@AbhiPrasad
Copy link

is it because c8 is re-exporting this via requiring another file? https://github.com/bcoe/c8/blob/1ec3cc41ff1aeb59bb040ee9c143a09054ac413b/index.js#L1

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 a pull request may close this issue.

3 participants