Skip to content

chore: update dependencies and refactor server types to use McpServer#38

Merged
hustcc merged 1 commit into
hustcc:mainfrom
hardikrathod777:main
Mar 27, 2026
Merged

chore: update dependencies and refactor server types to use McpServer#38
hustcc merged 1 commit into
hustcc:mainfrom
hardikrathod777:main

Conversation

@hardikrathod777

Copy link
Copy Markdown
Contributor

This PR updates the MCP server implementation to align with the newer @modelcontextprotocol/sdk API by migrating from the legacy Server class to the newer McpServer.

It also upgrades related dependencies and adjusts internal server usage to ensure compatibility with the updated SDK structure.

✨ Key Changes
🔁 Migration to McpServer
Replaced usage of Server with McpServer across the codebase
Updated server initialization:
new Server(...) → new McpServer(...)
Adjusted return types and function signatures accordingly
🔌 Handler API Updates
Updated request handler registration to use the new internal server instance:
server.setRequestHandler → server.server.setRequestHandler
Updated error handling:
server.onerror → server.server.onerror
🌐 Transport Layer Updates
Updated all transport services to accept McpServer instead of Server:
SSE (sse.ts)
STDIO (stdio.ts)
Streamable HTTP (streamable.ts)
📦 Dependency Upgrades
Upgraded MCP SDK:
@modelcontextprotocol/sdk → ^1.27.1
Upgraded inspector:
@modelcontextprotocol/inspector → ^0.21.1
🎯 Why This Change?
Ensure compatibility with the latest MCP SDK API
Adopt the new McpServer abstraction, which reflects current best practices
Fix potential issues caused by outdated handler and error APIs
Keep the project future-proof and aligned with upstream changes
⚠️ Breaking Changes
The server type has changed from Server → McpServer
Internal handler registration now requires accessing server.server
Any external integrations relying on the old Server type may need updates
🧪 Testing
Verified server initialization with McpServer
Tested all transport modes:
✅ SSE
✅ STDIO
✅ Streamable HTTP
Confirmed tool registration and execution still work as expected
🧹 Additional Notes
No functional changes to Mermaid generation logic
Changes are primarily structural and compatibility-focused
✅ Checklist
Updated to latest SDK
Refactored server implementation
Updated all transports
Tested locally
Documented breaking changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the project’s MCP server implementation to the newer @modelcontextprotocol/sdk API by replacing the legacy Server usage with McpServer, and updates related dependencies to match the upgraded SDK.

Changes:

  • Replaced Server with McpServer across server creation and transport entrypoints.
  • Updated handler/error registration to target the internal server instance (server.server.*).
  • Upgraded @modelcontextprotocol/sdk and @modelcontextprotocol/inspector versions in package.json.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/server.ts Migrates server creation to McpServer and updates handler/error wiring to the new API surface.
src/services/stdio.ts Updates stdio transport entrypoint to accept McpServer.
src/services/sse.ts Updates SSE transport entrypoint to accept McpServer.
src/services/streamable.ts Updates streamable HTTP transport entrypoint to accept McpServer.
package.json Bumps MCP SDK + inspector versions to match the migration.
Comments suppressed due to low confidence (1)

src/server.ts:27

  • The server metadata version is hard-coded to "0.1.3" here, but package.json is currently version 0.4.1. This can lead to clients/inspectors reporting the wrong server version; consider sourcing this from package.json (build-time injected) or updating it to match the package release version.
    {
      name: "mcp-mermaid",
      version: "0.1.3",
    },

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/server.ts
Comment on lines +45 to +50
function setupToolHandlers(server: McpServer): void {
server.server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [tool],
}));

server.setRequestHandler(CallToolRequestSchema, async (request) => {
server.server.setRequestHandler(CallToolRequestSchema, async (request) => {

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The migration to McpServer changes how request handlers and error handling are wired up (via server.server.*), but there are no automated tests covering server creation/handler registration. Adding a small unit test that instantiates createServer() and asserts ListTools/CallTool handlers are registered (and callable) would help catch SDK API regressions in future upgrades.

Copilot uses AI. Check for mistakes.
@hustcc

hustcc commented Mar 27, 2026

Copy link
Copy Markdown
Owner

@copilot 这个重构会导致这个 mcp 运行不起来吗?

@hustcc hustcc merged commit d35fe6c into hustcc:main Mar 27, 2026
5 checks passed
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.

3 participants