When we need to access the underlying server implementation this is what we have to do:
import { McpAgent } from "agents/mcp";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
export class MyMCP extends McpAgent {
server = new McpServer({/* ... */});
async init() {
// server.server echo is annoying and confusing
this.server.server.setRequestHandler(
SetLevelRequestSchema,
async (request, extra) => {
// ... handler logic
},
);
}
}
It's kind of annoying (and it's the MCP SKD's fault). I would rather it be this.mcp.server.setRequestHandler:
import { McpAgent } from "agents/mcp";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
export class MyMCP extends McpAgent {
mcp = new McpServer({/* ... */});
async init() {
this.mcp.server.setRequestHandler(
SetLevelRequestSchema,
async (request, extra) => {
// ... handler logic
},
);
}
}
However, McpAgent requires the server to be set to the server property.
This is just a small quality of life thing, but I think it should be easy enough to un-document the server name, document the mcp name, and support both.
When we need to access the underlying server implementation this is what we have to do:
It's kind of annoying (and it's the MCP SKD's fault). I would rather it be
this.mcp.server.setRequestHandler:However,
McpAgentrequires the server to be set to theserverproperty.This is just a small quality of life thing, but I think it should be easy enough to un-document the
servername, document themcpname, and support both.