@llamaindex/llama-cloud-mcp 1.3.0 → 1.5.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/code-tool.d.mts +4 -1
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +4 -1
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +14 -1
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +14 -1
- package/code-tool.mjs.map +1 -1
- package/http.d.mts +7 -2
- package/http.d.mts.map +1 -1
- package/http.d.ts +7 -2
- package/http.d.ts.map +1 -1
- package/http.js +25 -10
- package/http.js.map +1 -1
- package/http.mjs +25 -10
- package/http.mjs.map +1 -1
- package/index.js +6 -2
- package/index.js.map +1 -1
- package/index.mjs +6 -2
- package/index.mjs.map +1 -1
- package/methods.d.mts +10 -0
- package/methods.d.mts.map +1 -0
- package/methods.d.ts +10 -0
- package/methods.d.ts.map +1 -0
- package/methods.js +790 -0
- package/methods.js.map +1 -0
- package/methods.mjs +786 -0
- package/methods.mjs.map +1 -0
- package/options.d.mts +4 -0
- package/options.d.mts.map +1 -1
- package/options.d.ts +4 -0
- package/options.d.ts.map +1 -1
- package/options.js +30 -12
- package/options.js.map +1 -1
- package/options.mjs +30 -12
- package/options.mjs.map +1 -1
- package/package.json +13 -2
- package/server.d.mts +2 -3
- package/server.d.mts.map +1 -1
- package/server.d.ts +2 -3
- package/server.d.ts.map +1 -1
- package/server.js +40 -8
- package/server.js.map +1 -1
- package/server.mjs +39 -7
- package/server.mjs.map +1 -1
- package/src/code-tool.ts +20 -1
- package/src/http.ts +33 -10
- package/src/index.ts +6 -2
- package/src/methods.ts +810 -0
- package/src/options.ts +37 -12
- package/src/server.ts +49 -8
- package/src/stdio.ts +4 -3
- package/stdio.d.mts +2 -1
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts +2 -1
- package/stdio.d.ts.map +1 -1
- package/stdio.js +3 -3
- package/stdio.js.map +1 -1
- package/stdio.mjs +3 -3
- package/stdio.mjs.map +1 -1
package/src/http.ts
CHANGED
|
@@ -4,25 +4,29 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
|
4
4
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
5
5
|
import express from 'express';
|
|
6
6
|
import morgan from 'morgan';
|
|
7
|
+
import morganBody from 'morgan-body';
|
|
7
8
|
import { McpOptions } from './options';
|
|
8
9
|
import { ClientOptions, initMcpServer, newMcpServer } from './server';
|
|
9
10
|
import { parseAuthHeaders } from './headers';
|
|
10
11
|
|
|
11
|
-
const newServer = ({
|
|
12
|
+
const newServer = async ({
|
|
12
13
|
clientOptions,
|
|
14
|
+
mcpOptions,
|
|
13
15
|
req,
|
|
14
16
|
res,
|
|
15
17
|
}: {
|
|
16
18
|
clientOptions: ClientOptions;
|
|
19
|
+
mcpOptions: McpOptions;
|
|
17
20
|
req: express.Request;
|
|
18
21
|
res: express.Response;
|
|
19
|
-
}): McpServer | null => {
|
|
20
|
-
const server = newMcpServer();
|
|
22
|
+
}): Promise<McpServer | null> => {
|
|
23
|
+
const server = await newMcpServer();
|
|
21
24
|
|
|
22
25
|
try {
|
|
23
26
|
const authOptions = parseAuthHeaders(req, false);
|
|
24
|
-
initMcpServer({
|
|
27
|
+
await initMcpServer({
|
|
25
28
|
server: server,
|
|
29
|
+
mcpOptions: mcpOptions,
|
|
26
30
|
clientOptions: {
|
|
27
31
|
...clientOptions,
|
|
28
32
|
...authOptions,
|
|
@@ -45,7 +49,7 @@ const newServer = ({
|
|
|
45
49
|
const post =
|
|
46
50
|
(options: { clientOptions: ClientOptions; mcpOptions: McpOptions }) =>
|
|
47
51
|
async (req: express.Request, res: express.Response) => {
|
|
48
|
-
const server = newServer({ ...options, req, res });
|
|
52
|
+
const server = await newServer({ ...options, req, res });
|
|
49
53
|
// If we return null, we already set the authorization error.
|
|
50
54
|
if (server === null) return;
|
|
51
55
|
const transport = new StreamableHTTPServerTransport();
|
|
@@ -76,15 +80,30 @@ const del = async (req: express.Request, res: express.Response) => {
|
|
|
76
80
|
export const streamableHTTPApp = ({
|
|
77
81
|
clientOptions = {},
|
|
78
82
|
mcpOptions,
|
|
83
|
+
debug,
|
|
79
84
|
}: {
|
|
80
85
|
clientOptions?: ClientOptions;
|
|
81
86
|
mcpOptions: McpOptions;
|
|
87
|
+
debug: boolean;
|
|
82
88
|
}): express.Express => {
|
|
83
89
|
const app = express();
|
|
84
90
|
app.set('query parser', 'extended');
|
|
85
91
|
app.use(express.json());
|
|
86
|
-
app.use(morgan('combined'));
|
|
87
92
|
|
|
93
|
+
if (debug) {
|
|
94
|
+
morganBody(app, {
|
|
95
|
+
logAllReqHeader: true,
|
|
96
|
+
logAllResHeader: true,
|
|
97
|
+
logRequestBody: true,
|
|
98
|
+
logResponseBody: true,
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
app.use(morgan('combined'));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
app.get('/health', async (req: express.Request, res: express.Response) => {
|
|
105
|
+
res.status(200).send('OK');
|
|
106
|
+
});
|
|
88
107
|
app.get('/', get);
|
|
89
108
|
app.post('/', post({ clientOptions, mcpOptions }));
|
|
90
109
|
app.delete('/', del);
|
|
@@ -92,9 +111,13 @@ export const streamableHTTPApp = ({
|
|
|
92
111
|
return app;
|
|
93
112
|
};
|
|
94
113
|
|
|
95
|
-
export const launchStreamableHTTPServer = async (
|
|
96
|
-
|
|
97
|
-
|
|
114
|
+
export const launchStreamableHTTPServer = async (params: {
|
|
115
|
+
mcpOptions: McpOptions;
|
|
116
|
+
debug: boolean;
|
|
117
|
+
port: number | string | undefined;
|
|
118
|
+
}) => {
|
|
119
|
+
const app = streamableHTTPApp({ mcpOptions: params.mcpOptions, debug: params.debug });
|
|
120
|
+
const server = app.listen(params.port);
|
|
98
121
|
const address = server.address();
|
|
99
122
|
|
|
100
123
|
if (typeof address === 'string') {
|
|
@@ -102,6 +125,6 @@ export const launchStreamableHTTPServer = async (options: McpOptions, port: numb
|
|
|
102
125
|
} else if (address !== null) {
|
|
103
126
|
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
104
127
|
} else {
|
|
105
|
-
console.error(`MCP Server running on streamable HTTP on port ${port}`);
|
|
128
|
+
console.error(`MCP Server running on streamable HTTP on port ${params.port}`);
|
|
106
129
|
}
|
|
107
130
|
};
|
package/src/index.ts
CHANGED
|
@@ -18,10 +18,14 @@ async function main() {
|
|
|
18
18
|
|
|
19
19
|
switch (options.transport) {
|
|
20
20
|
case 'stdio':
|
|
21
|
-
await launchStdioServer();
|
|
21
|
+
await launchStdioServer(options);
|
|
22
22
|
break;
|
|
23
23
|
case 'http':
|
|
24
|
-
await launchStreamableHTTPServer(
|
|
24
|
+
await launchStreamableHTTPServer({
|
|
25
|
+
mcpOptions: options,
|
|
26
|
+
debug: options.debug,
|
|
27
|
+
port: options.port ?? options.socket,
|
|
28
|
+
});
|
|
25
29
|
break;
|
|
26
30
|
}
|
|
27
31
|
}
|