mcp-ts-template 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -53
- package/dist/mcp-server/server.js +1 -1
- package/dist/mcp-server/tools/catFactFetcher/index.d.ts +1 -1
- package/dist/mcp-server/tools/catFactFetcher/index.js +1 -1
- package/dist/mcp-server/tools/catFactFetcher/{catFactFetcherRegistration.js → registration.js} +1 -1
- package/dist/mcp-server/tools/echoTool/registration.js +1 -1
- package/package.json +1 -1
- /package/dist/mcp-server/tools/catFactFetcher/{catFactFetcherLogic.d.ts → logic.d.ts} +0 -0
- /package/dist/mcp-server/tools/catFactFetcher/{catFactFetcherLogic.js → logic.js} +0 -0
- /package/dist/mcp-server/tools/catFactFetcher/{catFactFetcherRegistration.d.ts → registration.d.ts} +0 -0
- /package/dist/mcp-server/tools/echoTool/{echoToolLogic.d.ts → logic.d.ts} +0 -0
- /package/dist/mcp-server/tools/echoTool/{echoToolLogic.js → logic.js} +0 -0
package/README.md
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
[](https://www.typescriptlang.org/)
|
|
4
4
|
[](https://github.com/modelcontextprotocol/typescript-sdk)
|
|
5
5
|
[](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-03-26/changelog.mdx)
|
|
6
|
-
[](./CHANGELOG.md)
|
|
7
7
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
8
8
|
[](https://github.com/cyanheads/mcp-ts-template/issues)
|
|
9
9
|
[](https://github.com/cyanheads/mcp-ts-template)
|
|
10
10
|
|
|
11
|
-
**Jumpstart your [Model Context Protocol (MCP) Client & Server](https://modelcontextprotocol.io/) development with this TypeScript Repo Template!**
|
|
11
|
+
**Jumpstart your [Model Context Protocol (MCP) Client & Server](https://modelcontextprotocol.io/) development with this TypeScript MCP Repo Template!**
|
|
12
12
|
|
|
13
13
|
This template provides a solid, beginner-friendly foundation for building robust MCP servers and clients, adhering to the **MCP 2025-03-26 specification**. It includes production-ready utilities, a well-structured codebase, working examples, and clear documentation to get you up and running quickly.
|
|
14
14
|
|
|
@@ -18,15 +18,14 @@ Whether you're creating a new MCP server to extend an AI's capabilities or integ
|
|
|
18
18
|
|
|
19
19
|
- [✨ Key Features](#-key-features)
|
|
20
20
|
- [🌟 Projects Using This Template](#-projects-using-this-template)
|
|
21
|
-
- [🏁 Quick Start](
|
|
21
|
+
- [🏁 Quick Start](#-quick-start)
|
|
22
22
|
- [⚙️ Configuration](#️-configuration)
|
|
23
|
-
- [🔩 Server Configuration (Environment Variables)](
|
|
24
|
-
- [🔌 Client Configuration (`src/mcp-client/client-config/mcp-config.json`)](#client-configuration-mcp-configjson)
|
|
23
|
+
- [🔩 Server Configuration (Environment Variables)](#-server-configuration-environment-variables)
|
|
25
24
|
- [🏗️ Project Structure](#️-project-structure)
|
|
26
|
-
- [🧩
|
|
25
|
+
- [🧩 Extending the MCP Server](#-extending-the-mcp-server)
|
|
27
26
|
- [🌍 More MCP Resources](#-explore-more-mcp-resources)
|
|
28
27
|
- [📜 License](#-license)
|
|
29
|
-
- [📊 Detailed Features Table](
|
|
28
|
+
- [📊 Detailed Features Table](#-detailed-features-table)
|
|
30
29
|
|
|
31
30
|
## ✨ Key Features
|
|
32
31
|
|
|
@@ -129,39 +128,9 @@ Configure the MCP server's behavior using these environment variables:
|
|
|
129
128
|
|
|
130
129
|
**Security Note for HTTP Transport:** When using `MCP_TRANSPORT_TYPE=http`, authentication is **mandatory** as per the MCP specification. This template includes JWT-based authentication middleware (`src/mcp-server/transports/authentication/authMiddleware.ts`). You **MUST** set a strong, unique `MCP_AUTH_SECRET_KEY` in your production environment for this security mechanism to function correctly. Failure to do so will result in bypassed authentication checks in development and fatal errors in production.
|
|
131
130
|
|
|
132
|
-
### 🔌 Client Configuration
|
|
133
|
-
|
|
134
|
-
Configure the connections for the built-in **MCP client** using `src/mcp-client/client-config/mcp-config.json`. If this file is missing, it falls back to `src/mcp-client/client-config/mcp-config.json.example`.
|
|
135
|
-
|
|
136
|
-
This file defines external MCP servers the client can connect to. The client implementation adheres to the **MCP 2025-03-26 specification**.
|
|
137
|
-
|
|
138
|
-
**Example `mcp-config.json` (see `src/mcp-client/client-config/mcp-config.json.example` for the full version):**
|
|
139
|
-
|
|
140
|
-
```json
|
|
141
|
-
{
|
|
142
|
-
"mcpServers": {
|
|
143
|
-
"my-stdio-server": {
|
|
144
|
-
"command": "node", // Command or executable
|
|
145
|
-
"args": ["/path/to/my-server/index.js"], // Arguments for stdio
|
|
146
|
-
"env": { "LOG_LEVEL": "debug" }, // Optional environment variables
|
|
147
|
-
"transportType": "stdio" // Explicitly stdio (or omit for default)
|
|
148
|
-
},
|
|
149
|
-
"my-http-server": {
|
|
150
|
-
"command": "http://localhost:8080", // Base URL for HTTP
|
|
151
|
-
"args": [], // Not used for HTTP
|
|
152
|
-
"env": {}, // Not used for HTTP
|
|
153
|
-
"transportType": "http" // Explicitly http
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
- **`command`**: Executable path (`stdio`) or Base URL (`http`).
|
|
160
|
-
- **`args`**: Array of arguments (required for `stdio`).
|
|
161
|
-
- **`env`**: Optional environment variables to set for the server process (`stdio`).
|
|
162
|
-
- **`transportType`**: `stdio` (default) or `http`.
|
|
131
|
+
### 🔌 Client Configuration
|
|
163
132
|
|
|
164
|
-
|
|
133
|
+
For detailed information on configuring the built-in **MCP client**, including how to set up connections to external MCP servers using `mcp-config.json`, please see the [Client Configuration Guide](src/mcp-client/client-config/README.md).
|
|
165
134
|
|
|
166
135
|
## 🏗️ Project Structure
|
|
167
136
|
|
|
@@ -198,21 +167,9 @@ npm run tree
|
|
|
198
167
|
|
|
199
168
|
(This uses `scripts/tree.ts` to generate a current file tree, respecting `.gitignore`.)
|
|
200
169
|
|
|
201
|
-
## 🧩
|
|
202
|
-
|
|
203
|
-
This template is designed for extension! Follow the high-level SDK patterns:
|
|
204
|
-
|
|
205
|
-
1. **Create Directories**: Add new directories under `src/mcp-server/tools/yourToolName/` or `src/mcp-server/resources/yourResourceName/`.
|
|
206
|
-
2. **Implement Logic (`logic.ts`)**: Define Zod schemas for inputs/outputs and write your core processing function.
|
|
207
|
-
3. **Register (`registration.ts`)**:
|
|
208
|
-
- **Tools**: Use `server.tool(name, description, zodSchemaShape, handler)` (SDK v1.10.2+). This handles schema generation, validation, and routing. Remember to add relevant annotations (`readOnlyHint`, `destructiveHint`, etc.) as untrusted hints.
|
|
209
|
-
- **Resources**: Use `server.resource(regName, template, metadata, handler)`.
|
|
210
|
-
- Wrap logic in `ErrorHandler.tryCatch` for robust error handling.
|
|
211
|
-
4. **Export & Import**: Export the registration function from your new directory's `index.ts` and call it within `createMcpServerInstance` in `src/mcp-server/server.ts`.
|
|
212
|
-
|
|
213
|
-
Refer to the included `EchoTool` and `EchoResource` examples and the [.clinerules](.clinerules) cheatsheet for detailed patterns.
|
|
170
|
+
## 🧩 Extending the MCP Server
|
|
214
171
|
|
|
215
|
-
For
|
|
172
|
+
For detailed guidance on how to add your own custom Tools and Resources to this MCP server template, including workflow examples and best practices, please see the [Server Extension Guide](src/mcp-server/README.md).
|
|
216
173
|
|
|
217
174
|
## 🌍 Explore More MCP Resources
|
|
218
175
|
|
|
@@ -17,8 +17,8 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
17
17
|
import { config, environment } from "../config/index.js";
|
|
18
18
|
import { ErrorHandler, logger, requestContextService } from "../utils/index.js";
|
|
19
19
|
import { registerEchoResource } from "./resources/echoResource/index.js";
|
|
20
|
-
import { registerEchoTool } from "./tools/echoTool/index.js";
|
|
21
20
|
import { registerCatFactFetcherTool } from "./tools/catFactFetcher/index.js";
|
|
21
|
+
import { registerEchoTool } from "./tools/echoTool/index.js";
|
|
22
22
|
import { startHttpTransport } from "./transports/httpTransport.js";
|
|
23
23
|
import { connectStdioTransport } from "./transports/stdioTransport.js";
|
|
24
24
|
/**
|
package/dist/mcp-server/tools/catFactFetcher/{catFactFetcherRegistration.js → registration.js}
RENAMED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { BaseErrorCode, McpError } from "../../../types-global/errors.js";
|
|
8
8
|
import { ErrorHandler, logger, requestContextService, } from "../../../utils/index.js";
|
|
9
|
-
import { CatFactFetcherInputSchema, processCatFactFetcher
|
|
9
|
+
import { CatFactFetcherInputSchema, processCatFactFetcher } from "./logic.js";
|
|
10
10
|
/**
|
|
11
11
|
* Registers the 'get_random_cat_fact' tool and its handler with the MCP server.
|
|
12
12
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { BaseErrorCode, McpError } from "../../../types-global/errors.js";
|
|
10
10
|
import { ErrorHandler, logger, requestContextService, } from "../../../utils/index.js";
|
|
11
|
-
import { EchoToolInputSchema, processEchoMessage } from "./
|
|
11
|
+
import { EchoToolInputSchema, processEchoMessage } from "./logic.js";
|
|
12
12
|
/**
|
|
13
13
|
* Registers the 'echo_message' tool and its handler with the provided MCP server instance.
|
|
14
14
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ts-template",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "TypeScript template for building Model Context Protocol (MCP) Servers & Clients. Features extensive utilities (logger, requestContext, etc.), STDIO & Streamable HTTP (with authMiddleware), examples, and type safety. Ideal starting point for creating production-ready MCP Servers & Clients.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
File without changes
|
|
File without changes
|
/package/dist/mcp-server/tools/catFactFetcher/{catFactFetcherRegistration.d.ts → registration.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|