poe-code 4.0.21 → 4.0.22
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/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/packages/tiny-http-mcp-server/dist/http-server.d.ts +2 -0
- package/packages/tiny-http-mcp-server/dist/http-server.js +3 -0
- package/packages/tiny-http-mcp-server/dist/index.d.ts +1 -1
- package/packages/tiny-http-mcp-server/dist/server.d.ts +1 -1
- package/packages/toolcraft/dist/http-hosted-oauth.compile-check.d.ts +1 -0
- package/packages/toolcraft/dist/http-hosted-oauth.compile-check.js +44 -0
- package/packages/toolcraft/dist/http-hosted-oauth.d.ts +113 -0
- package/packages/toolcraft/dist/http-hosted-oauth.js +422 -0
- package/packages/toolcraft/dist/http.d.ts +4 -2
- package/packages/toolcraft/dist/http.js +36 -4
|
@@ -2,6 +2,7 @@ import "./node-require-shim.js";
|
|
|
2
2
|
import { createHttpServer } from "tiny-http-mcp-server/server";
|
|
3
3
|
import { createMCPServerForTransport } from "./mcp.js";
|
|
4
4
|
import { enableSourceMaps } from "./stack-trim.js";
|
|
5
|
+
import { isHostedOAuthConfiguration, prepareHostedOAuthRuntime } from "./http-hosted-oauth.js";
|
|
5
6
|
function toVerifiedAccessToken(token, issuer, verified) {
|
|
6
7
|
return {
|
|
7
8
|
token,
|
|
@@ -62,7 +63,8 @@ function createTransportOptions(options, serverOptions) {
|
|
|
62
63
|
requestIdGenerator: options.requestIdGenerator,
|
|
63
64
|
observability: options.observability,
|
|
64
65
|
trustedProxy: options.trustedProxy,
|
|
65
|
-
oauth: options.oauth
|
|
66
|
+
oauth: options.oauth,
|
|
67
|
+
requestHandler: options.requestHandler
|
|
66
68
|
};
|
|
67
69
|
}
|
|
68
70
|
function createListenOptions(options) {
|
|
@@ -77,20 +79,50 @@ function createListenOptions(options) {
|
|
|
77
79
|
};
|
|
78
80
|
}
|
|
79
81
|
export async function createHTTPMCPServer(roots, options) {
|
|
82
|
+
let resolvedOptions = options;
|
|
83
|
+
let hostedMcpPath;
|
|
84
|
+
if (isHostedOAuthConfiguration(options.oauth)) {
|
|
85
|
+
const runtime = await prepareHostedOAuthRuntime(options.oauth);
|
|
86
|
+
const applicationServices = options.requestServices;
|
|
87
|
+
hostedMcpPath = runtime.mcpPath;
|
|
88
|
+
resolvedOptions = {
|
|
89
|
+
...options,
|
|
90
|
+
oauth: runtime.oauth,
|
|
91
|
+
sessionIdGenerator: undefined,
|
|
92
|
+
enableJsonResponse: true,
|
|
93
|
+
requestServices: async (context) => {
|
|
94
|
+
const subject = context.auth?.subject;
|
|
95
|
+
if (subject === undefined)
|
|
96
|
+
throw new Error("Hosted OAuth request is missing a verified subject.");
|
|
97
|
+
return {
|
|
98
|
+
...(applicationServices === undefined ? {} : await applicationServices(context)),
|
|
99
|
+
...(await runtime.requestServices(subject))
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
requestHandler: runtime.requestHandler
|
|
103
|
+
};
|
|
104
|
+
}
|
|
80
105
|
let server;
|
|
81
|
-
await createMCPServerForTransport(roots,
|
|
106
|
+
await createMCPServerForTransport(roots, resolvedOptions, {
|
|
82
107
|
createServer(serverOptions) {
|
|
83
|
-
server = createHttpServer(createTransportOptions(
|
|
108
|
+
server = createHttpServer(createTransportOptions(resolvedOptions, serverOptions));
|
|
84
109
|
return server;
|
|
85
110
|
},
|
|
86
111
|
getRequestContext() {
|
|
87
112
|
return server?.getRequestContext();
|
|
88
113
|
},
|
|
89
|
-
requestServices:
|
|
114
|
+
requestServices: resolvedOptions.requestServices
|
|
90
115
|
});
|
|
91
116
|
if (server === undefined) {
|
|
92
117
|
throw new Error("Toolcraft HTTP MCP server was not created.");
|
|
93
118
|
}
|
|
119
|
+
if (hostedMcpPath !== undefined) {
|
|
120
|
+
const listenHttp = server.listenHttp.bind(server);
|
|
121
|
+
server.listenHttp = (listenOptions = {}) => listenHttp({
|
|
122
|
+
path: hostedMcpPath,
|
|
123
|
+
...listenOptions
|
|
124
|
+
});
|
|
125
|
+
}
|
|
94
126
|
return server;
|
|
95
127
|
}
|
|
96
128
|
export async function runHTTPMCP(roots, options) {
|