@cyanheads/pubmed-mcp-server
Version:
Production-ready PubMed Model Context Protocol (MCP) server that empowers AI agents and research tools with comprehensive access to PubMed's article database. Enables advanced, automated LLM workflows for searching, retrieving, analyzing, and visualizing
58 lines • 1.93 kB
JavaScript
/**
* @fileoverview Defines a wrapper around the McpServer class to provide
* extended functionality, such as metadata introspection, without needing
* to access private properties of the underlying SDK class.
* @module src/mcp-server/core/managedMcpServer
*/
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
/**
* A wrapper around the McpServer that captures registration metadata
* to make it available for status endpoints and other diagnostics.
* It acts as a full pass-through for all McpServer functionality.
*/
export class ManagedMcpServer extends McpServer {
storedTools = [];
serverIdentity;
serverOptions;
constructor(identity, options) {
super(identity, options);
this.serverIdentity = identity;
this.serverOptions = options;
}
registerTool(name, spec, implementation) {
this.storedTools.push({ name, spec });
return super.registerTool(name, spec, implementation);
}
/**
* Retrieves the metadata for all registered tools.
*/
getTools() {
return this.storedTools.map((t) => ({
name: t.name,
description: t.spec.description,
inputSchema: t.spec.inputSchema,
outputSchema: t.spec.outputSchema,
}));
}
/**
* Gets the server's name from its identity.
*/
get name() {
return this.serverIdentity.name;
}
/**
* Gets the server's version from its identity.
*/
get version() {
return this.serverIdentity.version;
}
/**
* Gets the server's capabilities from its options.
*/
get capabilities() {
// The type inference for McpServerOptions is imperfect, so we cast to a
// known shape as a pragmatic solution, knowing the property exists at runtime.
return this.serverOptions?.capabilities;
}
}
//# sourceMappingURL=managedMcpServer.js.map