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 CHANGED
@@ -3,12 +3,12 @@
3
3
  [![TypeScript](https://img.shields.io/badge/TypeScript-^5.8.3-blue.svg)](https://www.typescriptlang.org/)
4
4
  [![Model Context Protocol SDK](https://img.shields.io/badge/MCP%20SDK-1.12.1-green.svg)](https://github.com/modelcontextprotocol/typescript-sdk)
5
5
  [![MCP Spec Version](https://img.shields.io/badge/MCP%20Spec-2025--03--26-lightgrey.svg)](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-03-26/changelog.mdx)
6
- [![Version](https://img.shields.io/badge/Version-1.4.2-blue.svg)](./CHANGELOG.md)
6
+ [![Version](https://img.shields.io/badge/Version-1.4.3-blue.svg)](./CHANGELOG.md)
7
7
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
8
8
  [![Status](https://img.shields.io/badge/Status-Stable-green.svg)](https://github.com/cyanheads/mcp-ts-template/issues)
9
9
  [![GitHub](https://img.shields.io/github/stars/cyanheads/mcp-ts-template?style=social)](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](#quick-start)
21
+ - [🏁 Quick Start](#-quick-start)
22
22
  - [⚙️ Configuration](#️-configuration)
23
- - [🔩 Server Configuration (Environment Variables)](#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
- - [🧩 Adding Tools/Resources](#-adding-your-own-tools--resources)
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](#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 (`src/mcp-client/client-config/mcp-config.json`)
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
- See `src/mcp-client/client-config/configLoader.ts` for the Zod validation schema and `src/mcp-client/client-config/mcp-config.json.example` for a complete example.
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
- ## 🧩 Adding Your Own Tools & Resources
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 an example of a tool that performs asynchronous operations, such as making an external API call, see the `get_random_cat_fact` tool located in `src/mcp-server/tools/catFactFetcher/`. This tool demonstrates how to use `async/await` within your tool's logic and handler, manage Promises, and integrate external data sources.
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
  /**
@@ -4,4 +4,4 @@
4
4
  * primarily exporting the `registerCatFactFetcherTool` function.
5
5
  * @module src/mcp-server/tools/catFactFetcher/index
6
6
  */
7
- export { registerCatFactFetcherTool } from "./catFactFetcherRegistration.js";
7
+ export { registerCatFactFetcherTool } from "./registration.js";
@@ -4,4 +4,4 @@
4
4
  * primarily exporting the `registerCatFactFetcherTool` function.
5
5
  * @module src/mcp-server/tools/catFactFetcher/index
6
6
  */
7
- export { registerCatFactFetcherTool } from "./catFactFetcherRegistration.js";
7
+ export { registerCatFactFetcherTool } from "./registration.js";
@@ -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, } from "./catFactFetcherLogic.js";
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 "./echoToolLogic.js";
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.2",
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": [