@tigerdata/mcp-boilerplate 0.1.0
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/LICENSE +177 -0
- package/README.md +56 -0
- package/dist/StatusError.js +7 -0
- package/dist/cliEntrypoint.js +42 -0
- package/dist/http/api.js +39 -0
- package/dist/http/mcp.js +153 -0
- package/dist/httpServer.js +67 -0
- package/dist/instrumentation.js +58 -0
- package/dist/logger.js +67 -0
- package/dist/mcpServer.js +104 -0
- package/dist/registerExitHandlers.js +26 -0
- package/dist/stdio.js +32 -0
- package/dist/tracing.js +59 -0
- package/dist/types.js +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# MCP Boilerplate for Node.js
|
|
2
|
+
|
|
3
|
+
This provides some common code for creating a [Model Context Protocol](https://modelcontextprotocol.io/introduction) (MCP) server in Node.js.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
1. Clone the repository:
|
|
8
|
+
```bash
|
|
9
|
+
git clone <repository-url>
|
|
10
|
+
cd mcp-boilerplate-node
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. Install dependencies:
|
|
14
|
+
```bash
|
|
15
|
+
npm install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Development
|
|
19
|
+
|
|
20
|
+
### Build
|
|
21
|
+
|
|
22
|
+
To build the TypeScript project:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm run build
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This compiles the TypeScript files from `src/` to JavaScript in `dist/`.
|
|
29
|
+
|
|
30
|
+
### Watch Mode
|
|
31
|
+
|
|
32
|
+
To run TypeScript compilation in watch mode (rebuilds on file changes):
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm run watch
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Linting
|
|
39
|
+
|
|
40
|
+
This project uses ESLint for code linting with TypeScript support.
|
|
41
|
+
|
|
42
|
+
To run the linter:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm run lint
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
To automatically fix linting issues where possible:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm run lint:fix
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Continuous Integration
|
|
55
|
+
|
|
56
|
+
The project includes GitHub Actions that automatically run linting checks on all pushes and pull requests to ensure code quality standards are maintained.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { dirname, join } from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
4
|
+
export async function cliEntrypoint(stdioEntrypoint, httpEntrypoint, instrumentation = join(__dirname, './instrumentation.js')) {
|
|
5
|
+
// Parse command line arguments first
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
const scriptName = args[0] || 'stdio';
|
|
8
|
+
try {
|
|
9
|
+
// Dynamically import only the requested module to prevent all modules from initializing
|
|
10
|
+
switch (scriptName) {
|
|
11
|
+
case 'stdio': {
|
|
12
|
+
// Import and run the stdio server
|
|
13
|
+
await import(stdioEntrypoint);
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
case 'http': {
|
|
17
|
+
let cleanup;
|
|
18
|
+
if (args.includes('--instrument') ||
|
|
19
|
+
process.env.INSTRUMENT === 'true') {
|
|
20
|
+
({ cleanup } = await import(instrumentation));
|
|
21
|
+
}
|
|
22
|
+
// Import and run the HTTP server
|
|
23
|
+
const { registerCleanupFn } = await import(httpEntrypoint);
|
|
24
|
+
if (cleanup && registerCleanupFn) {
|
|
25
|
+
registerCleanupFn(cleanup);
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
console.error(`Unknown script: ${scriptName}`);
|
|
31
|
+
console.log('Available scripts:');
|
|
32
|
+
console.log('- stdio');
|
|
33
|
+
console.log('- http');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error('Error running script:', error);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
}
|
package/dist/http/api.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST API alternative to MCP for direct use of the same tools.
|
|
3
|
+
*/
|
|
4
|
+
import { Router } from 'express';
|
|
5
|
+
import bodyParser from 'body-parser';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export const apiRouterFactory = (context, apiFactories) => {
|
|
8
|
+
const router = Router();
|
|
9
|
+
router.use(bodyParser.json());
|
|
10
|
+
for (const factory of apiFactories) {
|
|
11
|
+
const tool = factory(context);
|
|
12
|
+
if (!tool.method || !tool.route)
|
|
13
|
+
continue;
|
|
14
|
+
router[tool.method](tool.route, async (req, res) => {
|
|
15
|
+
const Input = z.object(tool.config.inputSchema);
|
|
16
|
+
const input = {
|
|
17
|
+
...req.params,
|
|
18
|
+
...req.query,
|
|
19
|
+
...req.body,
|
|
20
|
+
};
|
|
21
|
+
let parsedInput;
|
|
22
|
+
try {
|
|
23
|
+
parsedInput = Input.parse(input);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
res
|
|
27
|
+
.status(400)
|
|
28
|
+
.json({
|
|
29
|
+
error: 'zod validation failure',
|
|
30
|
+
issues: error.issues,
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const result = await tool.fn(parsedInput);
|
|
35
|
+
res.json(tool.pickResult ? tool.pickResult(result) : result);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return [router, () => { }];
|
|
39
|
+
};
|
package/dist/http/mcp.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
|
+
import { Router } from 'express';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
import getRawBody from 'raw-body';
|
|
6
|
+
import { log } from '../logger.js';
|
|
7
|
+
export const mcpRouterFactory = (context, createServer, stateful = true) => {
|
|
8
|
+
const router = Router();
|
|
9
|
+
const transports = new Map();
|
|
10
|
+
const handleStatelessRequest = async (req, res) => {
|
|
11
|
+
const { server } = createServer(context);
|
|
12
|
+
const transport = new StreamableHTTPServerTransport({
|
|
13
|
+
sessionIdGenerator: undefined,
|
|
14
|
+
});
|
|
15
|
+
res.on('close', () => {
|
|
16
|
+
transport.close();
|
|
17
|
+
server.close();
|
|
18
|
+
});
|
|
19
|
+
await server.connect(transport);
|
|
20
|
+
await transport.handleRequest(req, res, req.body);
|
|
21
|
+
};
|
|
22
|
+
const handleStatefulRequest = async (req, res) => {
|
|
23
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
24
|
+
let transport;
|
|
25
|
+
let body = req.body;
|
|
26
|
+
if (sessionId) {
|
|
27
|
+
if (!transports.has(sessionId)) {
|
|
28
|
+
res.status(404).json({
|
|
29
|
+
jsonrpc: '2.0',
|
|
30
|
+
error: {
|
|
31
|
+
code: -32000,
|
|
32
|
+
message: 'Not Found: No session found for that ID',
|
|
33
|
+
},
|
|
34
|
+
id: sessionId,
|
|
35
|
+
});
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
transport = transports.get(sessionId);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
if (!body) {
|
|
42
|
+
body = await getRawBody(req, {
|
|
43
|
+
limit: '4mb',
|
|
44
|
+
encoding: 'utf-8',
|
|
45
|
+
});
|
|
46
|
+
body = JSON.parse(body.toString());
|
|
47
|
+
}
|
|
48
|
+
if (!isInitializeRequest(body)) {
|
|
49
|
+
res.status(400).json({
|
|
50
|
+
jsonrpc: '2.0',
|
|
51
|
+
error: {
|
|
52
|
+
code: -32000,
|
|
53
|
+
message: 'Invalid request: Missing session ID',
|
|
54
|
+
},
|
|
55
|
+
id: null,
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
transport = new StreamableHTTPServerTransport({
|
|
60
|
+
sessionIdGenerator: () => randomUUID(),
|
|
61
|
+
onsessioninitialized: (sessionId) => {
|
|
62
|
+
log.info(`Session initialized with ID: ${sessionId}`);
|
|
63
|
+
transports.set(sessionId, transport);
|
|
64
|
+
},
|
|
65
|
+
onsessionclosed: (sessionId) => {
|
|
66
|
+
if (sessionId && transports.has(sessionId)) {
|
|
67
|
+
log.info(`Transport closed for session ${sessionId}, removing from transports map`);
|
|
68
|
+
transports.delete(sessionId);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
const { server } = createServer(context);
|
|
73
|
+
await server.connect(transport);
|
|
74
|
+
}
|
|
75
|
+
await transport.handleRequest(req, res, body);
|
|
76
|
+
};
|
|
77
|
+
router.post('/', async (req, res) => {
|
|
78
|
+
try {
|
|
79
|
+
await (stateful
|
|
80
|
+
? handleStatefulRequest(req, res)
|
|
81
|
+
: handleStatelessRequest(req, res));
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
log.error('Error handling MCP request:', error);
|
|
85
|
+
if (!res.headersSent) {
|
|
86
|
+
res.status(500).json({
|
|
87
|
+
jsonrpc: '2.0',
|
|
88
|
+
error: {
|
|
89
|
+
code: -32603,
|
|
90
|
+
message: 'Internal server error',
|
|
91
|
+
},
|
|
92
|
+
id: null,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
// Reusable handler for GET and DELETE requests
|
|
98
|
+
const handleSessionRequest = async (req, res) => {
|
|
99
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
100
|
+
if (!stateful) {
|
|
101
|
+
res.status(405).json({
|
|
102
|
+
jsonrpc: "2.0",
|
|
103
|
+
error: {
|
|
104
|
+
code: -32000,
|
|
105
|
+
message: "Method not allowed."
|
|
106
|
+
},
|
|
107
|
+
id: null
|
|
108
|
+
});
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (!sessionId) {
|
|
112
|
+
res.status(400).json({
|
|
113
|
+
jsonrpc: '2.0',
|
|
114
|
+
error: {
|
|
115
|
+
code: -32000,
|
|
116
|
+
message: 'Invalid request: Missing session ID',
|
|
117
|
+
},
|
|
118
|
+
id: null,
|
|
119
|
+
});
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (!transports.get(sessionId)) {
|
|
123
|
+
res.status(404).json({
|
|
124
|
+
jsonrpc: '2.0',
|
|
125
|
+
error: {
|
|
126
|
+
code: -32000,
|
|
127
|
+
message: 'Not Found: No session found for that ID',
|
|
128
|
+
},
|
|
129
|
+
id: sessionId,
|
|
130
|
+
});
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
await transports.get(sessionId).handleRequest(req, res);
|
|
134
|
+
};
|
|
135
|
+
// Handle GET requests for server-to-client notifications via SSE
|
|
136
|
+
router.get('/', handleSessionRequest);
|
|
137
|
+
// Handle DELETE requests for session termination
|
|
138
|
+
router.delete('/', handleSessionRequest);
|
|
139
|
+
const cleanup = async () => {
|
|
140
|
+
// Close all active transports to properly clean up resources
|
|
141
|
+
for (const sessionId in transports) {
|
|
142
|
+
try {
|
|
143
|
+
log.info(`Closing transport for session ${sessionId}`);
|
|
144
|
+
await transports.get(sessionId).close();
|
|
145
|
+
transports.delete(sessionId);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
log.error(`Error closing transport for session ${sessionId}:`, error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
return [router, cleanup];
|
|
153
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import { mcpRouterFactory } from './http/mcp.js';
|
|
4
|
+
import { apiRouterFactory } from './http/api.js';
|
|
5
|
+
import { registerExitHandlers } from './registerExitHandlers.js';
|
|
6
|
+
import { mcpServerFactory } from './mcpServer.js';
|
|
7
|
+
import { log } from './logger.js';
|
|
8
|
+
import { StatusError } from './StatusError.js';
|
|
9
|
+
export const httpServerFactory = ({ name, version, context, apiFactories = [], promptFactories = [], additionalSetup, cleanupFn, stateful = true, }) => {
|
|
10
|
+
const cleanupFns = cleanupFn
|
|
11
|
+
? [cleanupFn]
|
|
12
|
+
: [];
|
|
13
|
+
const exitHandler = registerExitHandlers(cleanupFns);
|
|
14
|
+
log.info('Starting HTTP server...');
|
|
15
|
+
const app = express();
|
|
16
|
+
const [mcpRouter, mcpCleanup] = mcpRouterFactory(context, () => mcpServerFactory({
|
|
17
|
+
name,
|
|
18
|
+
version,
|
|
19
|
+
context,
|
|
20
|
+
apiFactories,
|
|
21
|
+
promptFactories,
|
|
22
|
+
additionalSetup,
|
|
23
|
+
}), stateful);
|
|
24
|
+
cleanupFns.push(mcpCleanup);
|
|
25
|
+
app.use('/mcp', mcpRouter);
|
|
26
|
+
const [apiRouter, apiCleanup] = apiRouterFactory(context, apiFactories);
|
|
27
|
+
cleanupFns.push(apiCleanup);
|
|
28
|
+
app.use('/api', apiRouter);
|
|
29
|
+
// Error handler
|
|
30
|
+
app.use(function (err, req, res, _next) {
|
|
31
|
+
if (err instanceof StatusError && err.status < 500) {
|
|
32
|
+
log.info('HTTP error response', {
|
|
33
|
+
message: err.message,
|
|
34
|
+
status: err.status,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
log.error('Unexpected HTTP handler error', err);
|
|
39
|
+
}
|
|
40
|
+
res
|
|
41
|
+
.status(err instanceof StatusError ? err.status : 500)
|
|
42
|
+
.json({ error: err.message });
|
|
43
|
+
});
|
|
44
|
+
// Start the server
|
|
45
|
+
const PORT = process.env.PORT || 3001;
|
|
46
|
+
const server = app.listen(PORT, (error) => {
|
|
47
|
+
if (error) {
|
|
48
|
+
log.error('Error starting HTTP server:', error);
|
|
49
|
+
exitHandler(1);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
log.info(`HTTP Server listening on port ${PORT}`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
cleanupFns.push(async () => {
|
|
56
|
+
await server.close();
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
app,
|
|
60
|
+
server,
|
|
61
|
+
apiRouter,
|
|
62
|
+
mcpRouter,
|
|
63
|
+
registerCleanupFn: (fn) => {
|
|
64
|
+
cleanupFns.push(fn);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
2
|
+
import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
3
|
+
import { OTLPTraceExporter as GrpcTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
|
|
4
|
+
import { OTLPTraceExporter as HttpTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
5
|
+
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
6
|
+
import { BatchSpanProcessor, } from '@opentelemetry/sdk-trace-base';
|
|
7
|
+
import { BatchLogRecordProcessor, } from '@opentelemetry/sdk-logs';
|
|
8
|
+
import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
|
|
9
|
+
import { log } from './logger.js';
|
|
10
|
+
const spanProcessors = [];
|
|
11
|
+
const logRecordProcessors = [];
|
|
12
|
+
if (process.env.OTEL_EXPORTER_OTLP_ENDPOINT) {
|
|
13
|
+
spanProcessors.push(new BatchSpanProcessor(new GrpcTraceExporter()));
|
|
14
|
+
}
|
|
15
|
+
if (process.env.JAEGER_TRACES_ENDPOINT) {
|
|
16
|
+
spanProcessors.push(new BatchSpanProcessor(new GrpcTraceExporter({
|
|
17
|
+
url: process.env.JAEGER_TRACES_ENDPOINT,
|
|
18
|
+
})));
|
|
19
|
+
}
|
|
20
|
+
if (process.env.LOGFIRE_TRACES_ENDPOINT) {
|
|
21
|
+
spanProcessors.push(new BatchSpanProcessor(new HttpTraceExporter({
|
|
22
|
+
url: process.env.LOGFIRE_TRACES_ENDPOINT,
|
|
23
|
+
headers: process.env.LOGFIRE_TOKEN
|
|
24
|
+
? { Authorization: `Bearer ${process.env.LOGFIRE_TOKEN}` }
|
|
25
|
+
: {},
|
|
26
|
+
})));
|
|
27
|
+
}
|
|
28
|
+
if (process.env.LOGFIRE_LOGS_ENDPOINT) {
|
|
29
|
+
logRecordProcessors.push(new BatchLogRecordProcessor(new OTLPLogExporter({
|
|
30
|
+
url: process.env.LOGFIRE_LOGS_ENDPOINT,
|
|
31
|
+
headers: process.env.LOGFIRE_TOKEN
|
|
32
|
+
? { Authorization: `Bearer ${process.env.LOGFIRE_TOKEN}` }
|
|
33
|
+
: {},
|
|
34
|
+
})));
|
|
35
|
+
}
|
|
36
|
+
export const sdk = new NodeSDK({
|
|
37
|
+
instrumentations: [getNodeAutoInstrumentations()],
|
|
38
|
+
spanProcessors,
|
|
39
|
+
logRecordProcessors,
|
|
40
|
+
resource: resourceFromAttributes({
|
|
41
|
+
'deployment.environment.name': process.env.LOGFIRE_ENVIRONMENT || process.env.NODE_ENV || 'development',
|
|
42
|
+
'service.instance.id': process.env.HOSTNAME,
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
// Initialize the SDK and register with the OpenTelemetry API
|
|
46
|
+
sdk.start();
|
|
47
|
+
log.info('OpenTelemetry initialized');
|
|
48
|
+
export const cleanup = async () => {
|
|
49
|
+
try {
|
|
50
|
+
await Promise.all(spanProcessors.map((sp) => sp.shutdown()));
|
|
51
|
+
await Promise.all(logRecordProcessors.map((lp) => lp.shutdown()));
|
|
52
|
+
await sdk.shutdown();
|
|
53
|
+
log.info('OpenTelemetry terminated');
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
log.error('Error terminating OpenTelemetry', error);
|
|
57
|
+
}
|
|
58
|
+
};
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { logs, SeverityNumber } from '@opentelemetry/api-logs';
|
|
2
|
+
const name = process.env.OTEL_SERVICE_NAME || 'mcp-app';
|
|
3
|
+
const logger = logs.getLogger(name);
|
|
4
|
+
// Helper functions to replace console.log
|
|
5
|
+
export const log = {
|
|
6
|
+
debug: (...args) => {
|
|
7
|
+
console.debug(...args);
|
|
8
|
+
const [body, attributes] = args;
|
|
9
|
+
logger.emit({
|
|
10
|
+
severityText: 'DEBUG',
|
|
11
|
+
severityNumber: SeverityNumber.DEBUG,
|
|
12
|
+
body,
|
|
13
|
+
attributes: {
|
|
14
|
+
'log.level': 'debug',
|
|
15
|
+
'service.name': name,
|
|
16
|
+
...attributes,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
info: (...args) => {
|
|
21
|
+
console.info(...args);
|
|
22
|
+
const [body, attributes] = args;
|
|
23
|
+
logger.emit({
|
|
24
|
+
severityText: 'INFO',
|
|
25
|
+
severityNumber: SeverityNumber.INFO,
|
|
26
|
+
body,
|
|
27
|
+
attributes: {
|
|
28
|
+
'log.level': 'info',
|
|
29
|
+
'service.name': name,
|
|
30
|
+
...attributes,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
warn: (...args) => {
|
|
35
|
+
console.warn(...args);
|
|
36
|
+
const [body, attributes] = args;
|
|
37
|
+
logger.emit({
|
|
38
|
+
severityText: 'WARN',
|
|
39
|
+
severityNumber: SeverityNumber.WARN,
|
|
40
|
+
body,
|
|
41
|
+
attributes: {
|
|
42
|
+
'log.level': 'warn',
|
|
43
|
+
'service.name': name,
|
|
44
|
+
...attributes,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
error: (...args) => {
|
|
49
|
+
console.error(...args);
|
|
50
|
+
const [body, error, attributes] = args;
|
|
51
|
+
logger.emit({
|
|
52
|
+
severityText: 'ERROR',
|
|
53
|
+
severityNumber: SeverityNumber.ERROR,
|
|
54
|
+
body,
|
|
55
|
+
attributes: {
|
|
56
|
+
'log.level': 'error',
|
|
57
|
+
'service.name': name,
|
|
58
|
+
...(error && {
|
|
59
|
+
'error.name': error.name,
|
|
60
|
+
'error.message': error.message,
|
|
61
|
+
'error.stack': error.stack,
|
|
62
|
+
}),
|
|
63
|
+
...attributes,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { SpanStatusCode, trace } from '@opentelemetry/api';
|
|
3
|
+
import { log } from './logger.js';
|
|
4
|
+
const name = process.env.OTEL_SERVICE_NAME;
|
|
5
|
+
const tracer = trace.getTracer(name ? `${name}.mcpServer` : 'mcpServer');
|
|
6
|
+
const enabledTools = process.env.MCP_ENABLED_TOOLS
|
|
7
|
+
? new Set(process.env.MCP_ENABLED_TOOLS.split(',').map((s) => s.trim()))
|
|
8
|
+
: null;
|
|
9
|
+
const disabledTools = process.env.MCP_DISABLED_TOOLS
|
|
10
|
+
? new Set(process.env.MCP_DISABLED_TOOLS.split(',').map((s) => s.trim()))
|
|
11
|
+
: null;
|
|
12
|
+
export const mcpServerFactory = ({ name, version = '1.0.0', context, apiFactories, promptFactories = [], additionalSetup, }) => {
|
|
13
|
+
const server = new McpServer({
|
|
14
|
+
name,
|
|
15
|
+
version,
|
|
16
|
+
}, {
|
|
17
|
+
capabilities: {
|
|
18
|
+
tools: {},
|
|
19
|
+
...(promptFactories.length ? { prompts: {} } : null),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
for (const factory of apiFactories) {
|
|
23
|
+
const tool = factory(context);
|
|
24
|
+
if (enabledTools && !enabledTools.has(tool.name)) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (disabledTools && disabledTools.has(tool.name)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
server.registerTool(tool.name, {
|
|
31
|
+
...tool.config,
|
|
32
|
+
annotations: {
|
|
33
|
+
...tool.config.annotations,
|
|
34
|
+
// Some clients (e.g. claude code) do not yet support the title field
|
|
35
|
+
// at the top level and instead expect it in annotations. We also
|
|
36
|
+
// don't allow setting different titles in two places as that doesn't
|
|
37
|
+
// make sense.
|
|
38
|
+
title: tool.config.title,
|
|
39
|
+
},
|
|
40
|
+
}, async (args) => tracer.startActiveSpan(`mcp.tool.${tool.name}`, async (span) => {
|
|
41
|
+
span.setAttribute('mcp.tool.args', JSON.stringify(args));
|
|
42
|
+
try {
|
|
43
|
+
const result = await tool.fn(args);
|
|
44
|
+
const text = JSON.stringify(result);
|
|
45
|
+
span.setAttribute('mcp.tool.responseBytes', text.length);
|
|
46
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
47
|
+
return {
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: 'text',
|
|
51
|
+
text,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
structuredContent: result,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
log.error('Error invoking tool:', error);
|
|
59
|
+
span.recordException(error);
|
|
60
|
+
span.setStatus({
|
|
61
|
+
code: SpanStatusCode.ERROR,
|
|
62
|
+
message: error.message,
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
content: [
|
|
66
|
+
{
|
|
67
|
+
type: 'text',
|
|
68
|
+
text: `Error: ${error.message || 'Unknown error'}`,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
isError: true,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
span.end();
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
for (const factory of promptFactories) {
|
|
80
|
+
const prompt = factory(context);
|
|
81
|
+
server.registerPrompt(prompt.name, prompt.config, async (args) => tracer.startActiveSpan(`mcp.prompt.${prompt.name}`, async (span) => {
|
|
82
|
+
span.setAttribute('mcp.prompt.args', JSON.stringify(args));
|
|
83
|
+
try {
|
|
84
|
+
const result = await prompt.fn(args);
|
|
85
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
log.error('Error invoking prompt:', error);
|
|
90
|
+
span.recordException(error);
|
|
91
|
+
span.setStatus({
|
|
92
|
+
code: SpanStatusCode.ERROR,
|
|
93
|
+
message: error.message,
|
|
94
|
+
});
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
span.end();
|
|
99
|
+
}
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
additionalSetup?.({ context, server });
|
|
103
|
+
return { server };
|
|
104
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { log } from './logger.js';
|
|
2
|
+
let handlingExit = false;
|
|
3
|
+
export const registerExitHandlers = (cleanupFns) => {
|
|
4
|
+
const exitHandler = (code = 0) => {
|
|
5
|
+
if (handlingExit)
|
|
6
|
+
return;
|
|
7
|
+
handlingExit = true;
|
|
8
|
+
log.info('Shutting down server...');
|
|
9
|
+
Promise.allSettled(cleanupFns.map((fn) => fn())).finally(() => {
|
|
10
|
+
log.info('Server shutdown complete');
|
|
11
|
+
process.exit(code);
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
// Handle server shutdown
|
|
15
|
+
process.on('SIGINT', () => {
|
|
16
|
+
exitHandler();
|
|
17
|
+
});
|
|
18
|
+
process.on('SIGTERM', () => {
|
|
19
|
+
exitHandler();
|
|
20
|
+
});
|
|
21
|
+
process.on('uncaughtException', (err) => {
|
|
22
|
+
log.error('Uncaught Exception:', err);
|
|
23
|
+
exitHandler(1);
|
|
24
|
+
});
|
|
25
|
+
return exitHandler;
|
|
26
|
+
};
|
package/dist/stdio.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { mcpServerFactory } from './mcpServer.js';
|
|
4
|
+
import { registerExitHandlers } from './registerExitHandlers.js';
|
|
5
|
+
export const stdioServerFactory = async ({ name, version, context, apiFactories, promptFactories = [], additionalSetup, cleanupFn, }) => {
|
|
6
|
+
try {
|
|
7
|
+
console.error('Starting default (STDIO) server...');
|
|
8
|
+
const transport = new StdioServerTransport();
|
|
9
|
+
const { server } = mcpServerFactory({
|
|
10
|
+
name,
|
|
11
|
+
version,
|
|
12
|
+
context,
|
|
13
|
+
apiFactories,
|
|
14
|
+
promptFactories,
|
|
15
|
+
additionalSetup,
|
|
16
|
+
});
|
|
17
|
+
await server.connect(transport);
|
|
18
|
+
// Cleanup on exit
|
|
19
|
+
registerExitHandlers([
|
|
20
|
+
async () => {
|
|
21
|
+
await server.close();
|
|
22
|
+
},
|
|
23
|
+
async () => {
|
|
24
|
+
await cleanupFn?.();
|
|
25
|
+
},
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error('Server error:', error);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
};
|
package/dist/tracing.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { log } from './logger.js';
|
|
2
|
+
export const withSpan = async (tracer, name, fn) => {
|
|
3
|
+
return tracer.startActiveSpan(name, async (span) => {
|
|
4
|
+
try {
|
|
5
|
+
return await fn(span);
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
log.error(`Error in span ${name}`, error);
|
|
9
|
+
throw error;
|
|
10
|
+
}
|
|
11
|
+
finally {
|
|
12
|
+
span.end();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
const getToolContent = (content) => {
|
|
17
|
+
const { type, value } = content.output;
|
|
18
|
+
if (type === 'json' && value) {
|
|
19
|
+
if (typeof value === 'object' && 'structuredContent' in value) {
|
|
20
|
+
return value.structuredContent;
|
|
21
|
+
}
|
|
22
|
+
else if (typeof value === 'object' && 'content' in value) {
|
|
23
|
+
return value.content;
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
else if (value) {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
return content.output;
|
|
31
|
+
};
|
|
32
|
+
const annotateModelMessage = (m, i) => {
|
|
33
|
+
const msg = {
|
|
34
|
+
...m,
|
|
35
|
+
'event.name': `gen_ai.${m.role}.message`,
|
|
36
|
+
'gen_ai.message.index': Math.max(0, i - 1),
|
|
37
|
+
};
|
|
38
|
+
if (m.role === 'tool' && Array.isArray(m.content)) {
|
|
39
|
+
const [c] = m.content;
|
|
40
|
+
msg.id = c.toolCallId;
|
|
41
|
+
msg.name = c.toolName;
|
|
42
|
+
msg.content = getToolContent(c);
|
|
43
|
+
}
|
|
44
|
+
return msg;
|
|
45
|
+
};
|
|
46
|
+
export const addAiResultToSpan = (span, aiResult, inputMessages) => {
|
|
47
|
+
span.setAttribute('final_result', aiResult.text);
|
|
48
|
+
const messages = [...inputMessages, ...aiResult.response.messages].map(annotateModelMessage);
|
|
49
|
+
span.setAttribute('all_messages_events', JSON.stringify(messages));
|
|
50
|
+
// This is required for logfire to parse the events properly
|
|
51
|
+
span.setAttribute('logfire.json_schema', JSON.stringify({
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: { all_messages_events: { type: 'array' } },
|
|
54
|
+
}));
|
|
55
|
+
if (aiResult.totalUsage) {
|
|
56
|
+
span.setAttribute('gen_ai.usage.input_tokens', aiResult.totalUsage.inputTokens || 0);
|
|
57
|
+
span.setAttribute('gen_ai.usage.output_tokens', aiResult.totalUsage.outputTokens || 0);
|
|
58
|
+
}
|
|
59
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tigerdata/mcp-boilerplate",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP boilerplate code for Node.js",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"author": "TigerData",
|
|
7
|
+
"homepage": "https://tigerdata.com",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"prepare": "npm run build",
|
|
15
|
+
"watch": "tsc --watch",
|
|
16
|
+
"lint": "eslint",
|
|
17
|
+
"lint:fix": "eslint --fix"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@modelcontextprotocol/sdk": "^1.15.1",
|
|
21
|
+
"@opentelemetry/api": "^1.9.0",
|
|
22
|
+
"@opentelemetry/auto-instrumentations-node": "^0.62.0",
|
|
23
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "^0.203.0",
|
|
24
|
+
"@opentelemetry/instrumentation-http": "^0.203.0",
|
|
25
|
+
"@opentelemetry/sdk-metrics": "^2.0.1",
|
|
26
|
+
"@opentelemetry/sdk-node": "^0.203.0",
|
|
27
|
+
"@opentelemetry/sdk-trace-node": "^2.0.1",
|
|
28
|
+
"express": "^5.1.0",
|
|
29
|
+
"raw-body": "^3.0.1",
|
|
30
|
+
"zod": "^3.23.8"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@eslint/js": "^9.35.0",
|
|
34
|
+
"@types/express": "^5.0.3",
|
|
35
|
+
"@types/node": "^22.16.4",
|
|
36
|
+
"ai": "^5.0.17",
|
|
37
|
+
"eslint": "^9.35.0",
|
|
38
|
+
"prettier": "^3.6.2",
|
|
39
|
+
"typescript": "^5.8.3",
|
|
40
|
+
"typescript-eslint": "^8.43.0"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
}
|
|
45
|
+
}
|