@talonic/mcp 0.1.61 → 0.1.63
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-server.js +27 -42
- package/dist/http-server.js.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/server.js +9 -5
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/http-server.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { createServer as createServer$1 } from 'http';
|
|
2
|
-
import { randomUUID } from 'crypto';
|
|
3
2
|
import { realpathSync } from 'fs';
|
|
4
3
|
import { fileURLToPath } from 'url';
|
|
5
4
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
6
|
-
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
7
5
|
import { Talonic, TalonicError } from '@talonic/node';
|
|
8
6
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
7
|
import { z } from 'zod';
|
|
@@ -1190,9 +1188,13 @@ var inputSchema4 = {
|
|
|
1190
1188
|
};
|
|
1191
1189
|
var outputSchema4 = {
|
|
1192
1190
|
id: z.string(),
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1191
|
+
// Freshly-uploaded / pre-extraction documents (browser-handoff polling) return
|
|
1192
|
+
// null for these until OCR/ingest computes them. They MUST accept null, or the
|
|
1193
|
+
// SDK's outputSchema validation rejects the response with -32602 and the agent
|
|
1194
|
+
// cannot poll talonic_get_document after talonic_request_upload.
|
|
1195
|
+
filename: z.string().nullable().optional(),
|
|
1196
|
+
pages: z.number().nullable().optional(),
|
|
1197
|
+
size_bytes: z.number().nullable().optional(),
|
|
1196
1198
|
mime_type: z.string().nullable().optional(),
|
|
1197
1199
|
type_detected: z.string().nullable().optional(),
|
|
1198
1200
|
language_detected: z.string().nullable().optional(),
|
|
@@ -1215,7 +1217,7 @@ var outputSchema4 = {
|
|
|
1215
1217
|
confidentiality_marking: z.string().nullable().optional()
|
|
1216
1218
|
}).nullable().optional(),
|
|
1217
1219
|
original_path: z.string().nullable().optional(),
|
|
1218
|
-
extraction_count: z.number().optional(),
|
|
1220
|
+
extraction_count: z.number().nullable().optional(),
|
|
1219
1221
|
latest_extraction_id: z.string().nullable().optional(),
|
|
1220
1222
|
processing_log: z.array(
|
|
1221
1223
|
z.object({
|
|
@@ -1761,7 +1763,7 @@ function registerToMarkdown(server, getTalonic) {
|
|
|
1761
1763
|
|
|
1762
1764
|
// package.json
|
|
1763
1765
|
var package_default = {
|
|
1764
|
-
version: "0.1.
|
|
1766
|
+
version: "0.1.63"};
|
|
1765
1767
|
|
|
1766
1768
|
// src/version.ts
|
|
1767
1769
|
var VERSION = package_default.version;
|
|
@@ -1889,7 +1891,6 @@ function extractBearerToken(req) {
|
|
|
1889
1891
|
}
|
|
1890
1892
|
var WWW_AUTHENTICATE = `Bearer resource_metadata="${RESOURCE_URL}/.well-known/oauth-protected-resource"`;
|
|
1891
1893
|
function createRequestHandler() {
|
|
1892
|
-
const sessions = /* @__PURE__ */ new Map();
|
|
1893
1894
|
return async (req, res) => {
|
|
1894
1895
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
1895
1896
|
const path = url.pathname;
|
|
@@ -1986,17 +1987,6 @@ function createRequestHandler() {
|
|
|
1986
1987
|
);
|
|
1987
1988
|
return;
|
|
1988
1989
|
}
|
|
1989
|
-
if (req.method === "DELETE") {
|
|
1990
|
-
const sid = req.headers["mcp-session-id"];
|
|
1991
|
-
if (sid && sessions.has(sid)) {
|
|
1992
|
-
const session = sessions.get(sid);
|
|
1993
|
-
await session.transport.close();
|
|
1994
|
-
sessions.delete(sid);
|
|
1995
|
-
}
|
|
1996
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1997
|
-
res.end(JSON.stringify({ ok: true }));
|
|
1998
|
-
return;
|
|
1999
|
-
}
|
|
2000
1990
|
const token = extractBearerToken(req);
|
|
2001
1991
|
if (!token) {
|
|
2002
1992
|
res.writeHead(401, {
|
|
@@ -2011,11 +2001,19 @@ function createRequestHandler() {
|
|
|
2011
2001
|
);
|
|
2012
2002
|
return;
|
|
2013
2003
|
}
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2004
|
+
if (req.method === "DELETE") {
|
|
2005
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
2006
|
+
res.end(JSON.stringify({ ok: true }));
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
if (req.method === "GET") {
|
|
2010
|
+
res.writeHead(405, { "Content-Type": "application/json", Allow: "POST, DELETE, OPTIONS" });
|
|
2011
|
+
res.end(
|
|
2012
|
+
JSON.stringify({
|
|
2013
|
+
error: "method_not_allowed",
|
|
2014
|
+
message: "This MCP endpoint is stateless; send JSON-RPC over POST."
|
|
2015
|
+
})
|
|
2016
|
+
);
|
|
2019
2017
|
return;
|
|
2020
2018
|
}
|
|
2021
2019
|
const body = await new Promise((resolve) => {
|
|
@@ -2033,27 +2031,14 @@ function createRequestHandler() {
|
|
|
2033
2031
|
res.end(JSON.stringify({ error: "bad_request", message: "Invalid JSON body." }));
|
|
2034
2032
|
return;
|
|
2035
2033
|
}
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
message: "Unknown session. Re-initialize without the Mcp-Session-Id header."
|
|
2042
|
-
})
|
|
2043
|
-
);
|
|
2044
|
-
return;
|
|
2045
|
-
}
|
|
2046
|
-
const transport = new StreamableHTTPServerTransport({
|
|
2047
|
-
sessionIdGenerator: () => randomUUID()
|
|
2034
|
+
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: void 0 });
|
|
2035
|
+
const mcpServer = createServer({ tokenProvider: () => token });
|
|
2036
|
+
res.on("close", () => {
|
|
2037
|
+
void transport.close();
|
|
2038
|
+
void mcpServer.close();
|
|
2048
2039
|
});
|
|
2049
|
-
const tokenHolder = { current: token };
|
|
2050
|
-
const mcpServer = createServer({ tokenProvider: () => tokenHolder.current });
|
|
2051
2040
|
await mcpServer.connect(transport);
|
|
2052
2041
|
await transport.handleRequest(req, res, parsed);
|
|
2053
|
-
const newSessionId = transport.sessionId;
|
|
2054
|
-
if (newSessionId) {
|
|
2055
|
-
sessions.set(newSessionId, { transport, tokenHolder });
|
|
2056
|
-
}
|
|
2057
2042
|
};
|
|
2058
2043
|
}
|
|
2059
2044
|
function isDirectInvocation() {
|