@tigerdata/mcp-boilerplate 0.1.5 → 0.1.6

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/dist/http/mcp.js CHANGED
@@ -4,7 +4,7 @@ import { Router } from 'express';
4
4
  import { randomUUID } from 'node:crypto';
5
5
  import getRawBody from 'raw-body';
6
6
  import { log } from '../logger.js';
7
- export const mcpRouterFactory = (context, createServer, stateful = true) => {
7
+ export const mcpRouterFactory = (context, createServer, { name, stateful = true, } = {}) => {
8
8
  const router = Router();
9
9
  const transports = new Map();
10
10
  const handleStatelessRequest = async (req, res) => {
@@ -99,12 +99,12 @@ export const mcpRouterFactory = (context, createServer, stateful = true) => {
99
99
  const sessionId = req.headers['mcp-session-id'];
100
100
  if (!stateful) {
101
101
  res.status(405).json({
102
- jsonrpc: "2.0",
102
+ jsonrpc: '2.0',
103
103
  error: {
104
104
  code: -32000,
105
- message: "Method not allowed."
105
+ message: 'Method not allowed.',
106
106
  },
107
- id: null
107
+ id: null,
108
108
  });
109
109
  return;
110
110
  }
@@ -133,7 +133,33 @@ export const mcpRouterFactory = (context, createServer, stateful = true) => {
133
133
  await transports.get(sessionId).handleRequest(req, res);
134
134
  };
135
135
  // Handle GET requests for server-to-client notifications via SSE
136
- router.get('/', handleSessionRequest);
136
+ router.get('/', (req, res) => {
137
+ if (req.accepts('html')) {
138
+ const proto = req.headers['x-forwarded-proto'] || req.protocol;
139
+ const host = req.headers['x-forwarded-host'] || req.get('host');
140
+ const path = req.headers['x-original-request-uri'] ||
141
+ req.headers['x-original-uri'] ||
142
+ req.originalUrl;
143
+ const fullUrl = `${proto}://${host}${path}`;
144
+ res.send(`<!DOCTYPE html>
145
+ <html>
146
+ <head>
147
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
148
+ </head>
149
+ <body>
150
+ <h1>${name}</h1>
151
+ <h2>Model Context Protocol (MCP) Server</h2>
152
+ <p>This endpoint is used for MCP communication. Please use an MCP-compatible client to interact with this server.</p>
153
+
154
+ <h3>Claude Code</h3>
155
+ <p>To connect to this MCP server using Claude Code, run the following command in your terminal:</p>
156
+ <pre><code>claude mcp add --transport http ${name || req.get('host')} ${fullUrl}</code></pre>
157
+ </body>
158
+ </html>`);
159
+ return;
160
+ }
161
+ handleSessionRequest(req, res);
162
+ });
137
163
  // Handle DELETE requests for session termination
138
164
  router.delete('/', handleSessionRequest);
139
165
  const cleanup = async () => {
@@ -13,6 +13,7 @@ export const httpServerFactory = ({ name, version, context, apiFactories = [], p
13
13
  const exitHandler = registerExitHandlers(cleanupFns);
14
14
  log.info('Starting HTTP server...');
15
15
  const app = express();
16
+ app.enable('trust proxy');
16
17
  const [mcpRouter, mcpCleanup] = mcpRouterFactory(context, () => mcpServerFactory({
17
18
  name,
18
19
  version,
@@ -20,7 +21,7 @@ export const httpServerFactory = ({ name, version, context, apiFactories = [], p
20
21
  apiFactories,
21
22
  promptFactories,
22
23
  additionalSetup,
23
- }), stateful);
24
+ }), { name, stateful });
24
25
  cleanupFns.push(mcpCleanup);
25
26
  app.use('/mcp', mcpRouter);
26
27
  const [apiRouter, apiCleanup] = apiRouterFactory(context, apiFactories);
package/dist/mcpServer.js CHANGED
@@ -21,6 +21,8 @@ export const mcpServerFactory = ({ name, version = '1.0.0', context, apiFactorie
21
21
  });
22
22
  for (const factory of apiFactories) {
23
23
  const tool = factory(context);
24
+ if (tool.disabled)
25
+ continue;
24
26
  if (enabledTools && !enabledTools.has(tool.name)) {
25
27
  continue;
26
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tigerdata/mcp-boilerplate",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "MCP boilerplate code for Node.js",
5
5
  "license": "Apache-2.0",
6
6
  "author": "TigerData",