@decocms/runtime 1.2.7 → 1.2.9
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/package.json +2 -2
- package/src/bindings.ts +6 -0
- package/src/index.ts +1 -1
- package/src/oauth.ts +0 -21
- package/src/tools.ts +13 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/runtime",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"check": "tsc --noEmit",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@cloudflare/workers-types": "^4.20250617.0",
|
|
11
11
|
"@decocms/bindings": "^1.0.7",
|
|
12
|
-
"@modelcontextprotocol/sdk": "1.
|
|
12
|
+
"@modelcontextprotocol/sdk": "1.26.0",
|
|
13
13
|
"@ai-sdk/provider": "^3.0.0",
|
|
14
14
|
"hono": "^4.10.7",
|
|
15
15
|
"jose": "^6.0.11",
|
package/src/bindings.ts
CHANGED
|
@@ -108,6 +108,12 @@ export const proxyConnectionForId = (
|
|
|
108
108
|
headers ??= {};
|
|
109
109
|
headers.cookie = ctx.cookie;
|
|
110
110
|
}
|
|
111
|
+
|
|
112
|
+
if (ctx.token) {
|
|
113
|
+
headers ??= {};
|
|
114
|
+
headers["x-mesh-token"] = ctx.token;
|
|
115
|
+
}
|
|
116
|
+
|
|
111
117
|
return {
|
|
112
118
|
type: "HTTP",
|
|
113
119
|
url: new URL(`/mcp/${connectionId}`, ctx.meshUrl).href,
|
package/src/index.ts
CHANGED
|
@@ -195,7 +195,7 @@ export const withBindings = <TEnv>({
|
|
|
195
195
|
|
|
196
196
|
context = {
|
|
197
197
|
authorization,
|
|
198
|
-
state: decoded.state ?? metadata.state,
|
|
198
|
+
state: decoded.state ?? metadata.state ?? {},
|
|
199
199
|
token: tokenOrContext,
|
|
200
200
|
meshUrl: (decoded.meshUrl as string) ?? metadata.meshUrl,
|
|
201
201
|
connectionId: (decoded.connectionId as string) ?? metadata.connectionId,
|
package/src/oauth.ts
CHANGED
|
@@ -70,27 +70,6 @@ interface CodePayload {
|
|
|
70
70
|
codeChallengeMethod?: string;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
/**
|
|
74
|
-
* OAuth 2.0/2.1 Token Request Parameters
|
|
75
|
-
* Per RFC 6749 (OAuth 2.0) and RFC 9207 (OAuth 2.1)
|
|
76
|
-
* All parameters are strings when properly formatted
|
|
77
|
-
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.3
|
|
78
|
-
*/
|
|
79
|
-
interface OAuthTokenRequestBody {
|
|
80
|
-
/** REQUIRED for authorization_code grant - The authorization code from callback */
|
|
81
|
-
code?: string;
|
|
82
|
-
/** OPTIONAL - PKCE code verifier (RFC 7636) */
|
|
83
|
-
code_verifier?: string;
|
|
84
|
-
/** REQUIRED - Grant type: "authorization_code" or "refresh_token" */
|
|
85
|
-
grant_type?: string;
|
|
86
|
-
/** REQUIRED for refresh_token grant - The refresh token */
|
|
87
|
-
refresh_token?: string;
|
|
88
|
-
/** OPTIONAL - Redirect URI used in authorization request */
|
|
89
|
-
redirect_uri?: string;
|
|
90
|
-
/** Additional provider-specific parameters */
|
|
91
|
-
[key: string]: unknown;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
73
|
const forceHttps = (url: URL) => {
|
|
95
74
|
const isLocal = url.hostname === "localhost" || url.hostname === "127.0.0.1";
|
|
96
75
|
if (!isLocal) {
|
package/src/tools.ts
CHANGED
|
@@ -7,7 +7,10 @@ import {
|
|
|
7
7
|
} from "@decocms/bindings";
|
|
8
8
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
9
|
import { WebStandardStreamableHTTPServerTransport as HttpServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
10
|
-
import type {
|
|
10
|
+
import type {
|
|
11
|
+
GetPromptResult,
|
|
12
|
+
ToolAnnotations,
|
|
13
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
11
14
|
import { z } from "zod";
|
|
12
15
|
import type { ZodRawShape, ZodSchema, ZodTypeAny } from "zod";
|
|
13
16
|
import { BindingRegistry } from "./bindings.ts";
|
|
@@ -47,6 +50,7 @@ export interface Tool<
|
|
|
47
50
|
_meta?: Record<string, unknown>;
|
|
48
51
|
id: string;
|
|
49
52
|
description?: string;
|
|
53
|
+
annotations?: ToolAnnotations;
|
|
50
54
|
inputSchema: TSchemaIn;
|
|
51
55
|
outputSchema?: TSchemaOut;
|
|
52
56
|
execute(
|
|
@@ -76,6 +80,7 @@ export type CreatedTool = {
|
|
|
76
80
|
_meta?: Record<string, unknown>;
|
|
77
81
|
id: string;
|
|
78
82
|
description?: string;
|
|
83
|
+
annotations?: ToolAnnotations;
|
|
79
84
|
inputSchema: ZodTypeAny;
|
|
80
85
|
outputSchema?: ZodTypeAny;
|
|
81
86
|
streamable?: true;
|
|
@@ -86,8 +91,11 @@ export type CreatedTool = {
|
|
|
86
91
|
}): Promise<unknown>;
|
|
87
92
|
};
|
|
88
93
|
|
|
89
|
-
// Re-export
|
|
90
|
-
export type {
|
|
94
|
+
// Re-export types for external use
|
|
95
|
+
export type {
|
|
96
|
+
GetPromptResult,
|
|
97
|
+
ToolAnnotations,
|
|
98
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
91
99
|
|
|
92
100
|
/**
|
|
93
101
|
* Prompt argument schema shape - must be string types per MCP specification.
|
|
@@ -530,7 +538,7 @@ const getEventBus = (
|
|
|
530
538
|
const bus = env as unknown as { [prop]: EventBusBindingClient };
|
|
531
539
|
return typeof bus[prop] !== "undefined"
|
|
532
540
|
? bus[prop]
|
|
533
|
-
: env?.MESH_REQUEST_CONTEXT
|
|
541
|
+
: env?.MESH_REQUEST_CONTEXT?.state?.[prop];
|
|
534
542
|
};
|
|
535
543
|
|
|
536
544
|
const toolsFor = <TSchema extends ZodTypeAny = never>({
|
|
@@ -713,6 +721,7 @@ export const createMCPServer = <
|
|
|
713
721
|
...(tool._meta ?? {}),
|
|
714
722
|
},
|
|
715
723
|
description: tool.description,
|
|
724
|
+
annotations: tool.annotations,
|
|
716
725
|
inputSchema:
|
|
717
726
|
tool.inputSchema && "shape" in tool.inputSchema
|
|
718
727
|
? (tool.inputSchema.shape as ZodRawShape)
|