From 6f0dcf464fec41dc1112906c3e693e0aefd98f54 Mon Sep 17 00:00:00 2001 From: Jason Kneen Date: Wed, 22 Jan 2025 21:46:07 +0000 Subject: [PATCH 1/2] Fix MCP inspector connection with TypeScript SDK server Fixes #129 Update README.md to include instructions for running the server with the MCP inspector and update the quickstart example. * Add instructions for running the server with the MCP inspector. * Update the quickstart example to include the `StdioServerTransport` connection. * Add sections for Development Mode, Claude Desktop Integration, and Direct Execution. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/modelcontextprotocol/typescript-sdk/issues/129?shareId=XXXX-XXXX-XXXX-XXXX). --- README.md | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c5d037a..b39b284e 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,11 @@ server.resource( }] }) ); + +// Connect to a transport +import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; +const transport = new StdioServerTransport(); +await server.connect(transport); ``` ## What is MCP? @@ -385,7 +390,6 @@ const client = new Client( resources: {}, tools: {} } - } ); await client.connect(transport); @@ -410,6 +414,37 @@ const result = await client.callTool("example-tool", { }); ``` +## Running Your Server + +### Development Mode + +To run your server in development mode, you can use the following command: + +```bash +npm run dev +``` + +This will start your server with hot-reloading enabled, so any changes you make to your code will automatically restart the server. + +### Claude Desktop Integration + +To integrate your server with Claude Desktop, follow these steps: + +1. Install Claude Desktop from the official website. +2. Configure Claude Desktop to connect to your MCP server by specifying the server's address and port. +3. Start your MCP server and ensure it is running. +4. Launch Claude Desktop and verify the connection to your MCP server. + +### Direct Execution + +To run your server directly, use the following command: + +```bash +node dist/index.js +``` + +This will start your server using the compiled JavaScript files in the `dist` directory. + ## Documentation - [Model Context Protocol documentation](https://modelcontextprotocol.io) From 8f1b4b0072a22f3f5b8580a7e72022808dc0c218 Mon Sep 17 00:00:00 2001 From: Jason Kneen Date: Wed, 22 Jan 2025 22:11:23 +0000 Subject: [PATCH 2/2] Add instructions for running the server with the MCP inspector * **Running with MCP Inspector** - Add steps to install MCP Inspector globally using npm - Add steps to start the MCP server - Add steps to start the MCP Inspector and connect it to the running server --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index b39b284e..cfa91d48 100644 --- a/README.md +++ b/README.md @@ -445,6 +445,27 @@ node dist/index.js This will start your server using the compiled JavaScript files in the `dist` directory. +### Running with MCP Inspector + +To run your server with the MCP Inspector, follow these steps: + +1. Install the MCP Inspector globally using npm: + ```bash + npm install -g @modelcontextprotocol/inspector + ``` + +2. Start your MCP server: + ```bash + npm run start + ``` + +3. In a separate terminal, start the MCP Inspector and connect it to your running server: + ```bash + npx @modelcontextprotocol/inspector npm run -s start + ``` + +This will start the MCP Inspector and connect it to your running server, allowing you to inspect and interact with your server's resources, tools, and prompts. + ## Documentation - [Model Context Protocol documentation](https://modelcontextprotocol.io)