mcp-use 2.0.0-beta.28 → 2.0.0-beta.29
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/{chunk-26JBVQUY.js → chunk-QKJJ6DWK.js} +0 -18
- package/dist/config.d.ts +5 -5
- package/dist/context.d.ts +14 -7
- package/dist/fetch-app.d.ts +3 -27
- package/dist/index.d.ts +21 -8
- package/dist/index.js +478 -190
- package/dist/{mcp-proxy-QYZQ6LNV.js → mcp-proxy-JK7IC5CR.js} +2 -2
- package/dist/middleware/mcp-middleware.d.ts +32 -27
- package/dist/next/index.js +1 -1
- package/dist/oauth/index.js +1 -1
- package/dist/prompts.d.ts +7 -3
- package/dist/react/hooks/use-call-tool.d.ts +29 -11
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +7 -0
- package/dist/react/types/register.d.ts +10 -2
- package/dist/resources.d.ts +14 -5
- package/dist/response-conversion.d.ts +25 -0
- package/dist/response-helpers.d.ts +223 -0
- package/dist/server.d.ts +62 -68
- package/dist/tools.d.ts +5 -4
- package/dist/views/routes.d.ts +1 -1
- package/package.json +6 -5
|
@@ -26,12 +26,6 @@ import {
|
|
|
26
26
|
hostHeaderValidationResponse,
|
|
27
27
|
originValidationResponse
|
|
28
28
|
} from "@modelcontextprotocol/server";
|
|
29
|
-
function toFrameworkHandler(fetch) {
|
|
30
|
-
return (input) => {
|
|
31
|
-
const request = input instanceof Request ? input : input.req.raw;
|
|
32
|
-
return fetch(request);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
29
|
var requestBags = /* @__PURE__ */ new WeakMap();
|
|
36
30
|
function getRequestBag(request) {
|
|
37
31
|
let bag = requestBags.get(request);
|
|
@@ -88,16 +82,6 @@ function isHtmlNavigationRequest(request) {
|
|
|
88
82
|
});
|
|
89
83
|
});
|
|
90
84
|
}
|
|
91
|
-
function routeFetch(routes, fallback = async () => new Response("Not Found", { status: 404 })) {
|
|
92
|
-
return async (request) => {
|
|
93
|
-
for (const route of routes) {
|
|
94
|
-
if (route.match(request)) {
|
|
95
|
-
return route.handler(request);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return fallback(request);
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
85
|
function jsonBodyMiddleware() {
|
|
102
86
|
return async (request, next) => {
|
|
103
87
|
const bag = getRequestBag(request);
|
|
@@ -177,7 +161,6 @@ function authInfoFromRequest(request) {
|
|
|
177
161
|
}
|
|
178
162
|
|
|
179
163
|
export {
|
|
180
|
-
toFrameworkHandler,
|
|
181
164
|
getRequestBag,
|
|
182
165
|
composeFetch,
|
|
183
166
|
pathnameOf,
|
|
@@ -185,7 +168,6 @@ export {
|
|
|
185
168
|
matchesPathPrefix,
|
|
186
169
|
pathUnderBase,
|
|
187
170
|
isHtmlNavigationRequest,
|
|
188
|
-
routeFetch,
|
|
189
171
|
jsonBodyMiddleware,
|
|
190
172
|
hostValidationMiddleware,
|
|
191
173
|
originValidationMiddleware,
|
package/dist/config.d.ts
CHANGED
|
@@ -107,8 +107,8 @@ interface BaseServerConfig {
|
|
|
107
107
|
* binds get DNS-rebinding protection (`Host` on every request; `Origin`
|
|
108
108
|
* only on non-GET/HEAD) automatically. Set `"0.0.0.0"` to serve publicly — behind a platform
|
|
109
109
|
* edge (Railway, Fly, …) nothing more is needed, since the edge only
|
|
110
|
-
* routes hostnames assigned to the deployment. Ignored by `
|
|
111
|
-
* which never binds.
|
|
110
|
+
* routes hostnames assigned to the deployment. Ignored by `server.fetch`,
|
|
111
|
+
* which never binds a socket.
|
|
112
112
|
*/
|
|
113
113
|
host?: string;
|
|
114
114
|
/**
|
|
@@ -123,7 +123,7 @@ interface BaseServerConfig {
|
|
|
123
123
|
* protection), e.g. `["api.example.com"]`. Port-agnostic and additive:
|
|
124
124
|
* localhost-class hostnames stay allowed, so local runs keep working
|
|
125
125
|
* unmodified. Setting this also turns Host validation on for
|
|
126
|
-
* `
|
|
126
|
+
* `server.fetch`, which otherwise applies none.
|
|
127
127
|
*/
|
|
128
128
|
allowedHosts?: string[];
|
|
129
129
|
/**
|
|
@@ -186,7 +186,7 @@ interface BaseServerConfig {
|
|
|
186
186
|
*/
|
|
187
187
|
requestState?: ServerOptions["requestState"];
|
|
188
188
|
/**
|
|
189
|
-
* Optional CORS headers on every route served by `
|
|
189
|
+
* Optional CORS headers on every route served by `server.fetch` / `listen()`
|
|
190
190
|
* (MCP endpoint, view assets, landing page, OAuth metadata). Off when omitted.
|
|
191
191
|
*
|
|
192
192
|
* Pair with {@link BaseServerConfig.allowedOrigins | allowedOrigins} for
|
|
@@ -209,7 +209,7 @@ interface BaseServerConfig {
|
|
|
209
209
|
cors?: CorsOptions;
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
212
|
-
* CORS configuration for routes owned by
|
|
212
|
+
* CORS configuration for routes owned by the Hono application.
|
|
213
213
|
*
|
|
214
214
|
* Omit `cors` entirely for the current no-CORS behavior. Pass `cors: {}` to
|
|
215
215
|
* enable with defaults (reflects the request `Origin` when present; wildcard
|
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type InputRequiredResult, type RequestStateAccessor, type ServerContext, type StandardSchemaWithJSON } from "@modelcontextprotocol/server";
|
|
2
|
+
import type { Context, Env, HonoRequest as HonoRequestType } from "hono";
|
|
2
3
|
/**
|
|
3
4
|
* Per-request client capability queries.
|
|
4
5
|
*
|
|
@@ -79,11 +80,17 @@ export type OAuthAuth<TUser> = {
|
|
|
79
80
|
expiresAt: number;
|
|
80
81
|
resource?: URL;
|
|
81
82
|
};
|
|
82
|
-
type RequestContextBase = {
|
|
83
|
+
type RequestContextBase<TEnv extends Env> = Omit<Context<TEnv>, "req"> & {
|
|
83
84
|
/** Aborted when the client cancels the request or the connection drops. */
|
|
84
85
|
signal: AbortSignal;
|
|
85
|
-
/**
|
|
86
|
-
request?:
|
|
86
|
+
/** Hono request for the originating HTTP exchange. Its raw Web Request is available as `request.raw`. */
|
|
87
|
+
request?: HonoRequestType;
|
|
88
|
+
/**
|
|
89
|
+
* Deprecated v1-compatible alias for {@link RequestContext.request}.
|
|
90
|
+
*
|
|
91
|
+
* @deprecated Use `request` instead.
|
|
92
|
+
*/
|
|
93
|
+
req?: HonoRequestType;
|
|
87
94
|
/** Per-request client capability queries. */
|
|
88
95
|
client: RequestClientContext;
|
|
89
96
|
/** Request or read a keyed form- or URL-mode elicitation. */
|
|
@@ -112,9 +119,9 @@ type RequestContextBase = {
|
|
|
112
119
|
/**
|
|
113
120
|
* Per-request callback context, authenticated when OAuth is configured.
|
|
114
121
|
*/
|
|
115
|
-
export type RequestContext<TUser = never, HasOAuth extends boolean = false> = HasOAuth extends true ? RequestContextBase & {
|
|
122
|
+
export type RequestContext<TUser = never, HasOAuth extends boolean = false, TEnv extends Env = Env> = HasOAuth extends true ? RequestContextBase<TEnv> & {
|
|
116
123
|
auth: OAuthAuth<TUser>;
|
|
117
|
-
} : RequestContextBase & {
|
|
124
|
+
} : RequestContextBase<TEnv> & {
|
|
118
125
|
auth?: never;
|
|
119
126
|
};
|
|
120
127
|
/**
|
|
@@ -123,7 +130,7 @@ export type RequestContext<TUser = never, HasOAuth extends boolean = false> = Ha
|
|
|
123
130
|
*
|
|
124
131
|
* @internal
|
|
125
132
|
*/
|
|
126
|
-
export declare function toRequestContext(ctx: ServerContext): RequestContext<never, false>;
|
|
133
|
+
export declare function toRequestContext<TEnv extends Env = Env>(ctx: ServerContext): RequestContext<never, false, TEnv>;
|
|
127
134
|
/** @internal Projects mapped OAuth auth information into callback context. */
|
|
128
|
-
export declare function toAuthenticatedRequestContext<TUser>(ctx: ServerContext): RequestContext<TUser, true>;
|
|
135
|
+
export declare function toAuthenticatedRequestContext<TUser, TEnv extends Env = Env>(ctx: ServerContext): RequestContext<TUser, true, TEnv>;
|
|
129
136
|
export {};
|
package/dist/fetch-app.d.ts
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
1
|
import { type AuthInfo } from "@modelcontextprotocol/server";
|
|
2
|
+
import type { Context, Env } from "hono";
|
|
2
3
|
/** Web-standard request handler. */
|
|
3
4
|
export type FetchHandler = (request: Request) => Promise<Response>;
|
|
4
|
-
/** Request shapes accepted by {@link toFrameworkHandler}. */
|
|
5
|
-
export type FrameworkRequestLike = Request | {
|
|
6
|
-
req: {
|
|
7
|
-
raw: Request;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Universal web handler mountable in Vercel, Hono, TanStack, and other
|
|
12
|
-
* fetch-native frameworks without `c.req.raw` boilerplate.
|
|
13
|
-
*/
|
|
14
|
-
export type FrameworkHandler = (input: FrameworkRequestLike) => Promise<Response>;
|
|
15
|
-
/**
|
|
16
|
-
* Wrap a {@link FetchHandler} for framework duck-typing (Hono `Context`, etc.).
|
|
17
|
-
*
|
|
18
|
-
* @param fetch - Inner fetch handler produced by {@link MCPServer.getHandler}.
|
|
19
|
-
*/
|
|
20
|
-
export declare function toFrameworkHandler(fetch: FetchHandler): FrameworkHandler;
|
|
21
5
|
/** Onion middleware over a {@link FetchHandler} terminal. */
|
|
22
6
|
export type FetchMiddleware = (request: Request, next: () => Promise<Response>) => Promise<Response>;
|
|
23
7
|
/** Per-request values stashed before the MCP handler runs. */
|
|
@@ -26,6 +10,8 @@ export interface RequestBag {
|
|
|
26
10
|
parsedBody?: unknown;
|
|
27
11
|
/** Verified OAuth identity forwarded to the SDK handler. */
|
|
28
12
|
authInfo?: AuthInfo;
|
|
13
|
+
/** Hono context associated with this request while it traverses the app. */
|
|
14
|
+
honoContext?: Context<Env>;
|
|
29
15
|
}
|
|
30
16
|
/**
|
|
31
17
|
* Mutable per-request bag; created on first access.
|
|
@@ -86,16 +72,6 @@ export declare function pathUnderBase(basePath: string, childPath: string): stri
|
|
|
86
72
|
* @internal
|
|
87
73
|
*/
|
|
88
74
|
export declare function isHtmlNavigationRequest(request: Request): boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Dispatch to the first matching route handler.
|
|
91
|
-
*
|
|
92
|
-
* @param routes - Ordered route table; first match wins.
|
|
93
|
-
* @param fallback - Handler when nothing matches.
|
|
94
|
-
*/
|
|
95
|
-
export declare function routeFetch(routes: Array<{
|
|
96
|
-
match: (request: Request) => boolean;
|
|
97
|
-
handler: FetchHandler;
|
|
98
|
-
}>, fallback?: FetchHandler): FetchHandler;
|
|
99
75
|
/**
|
|
100
76
|
* Parse JSON bodies once and stash them in the request bag.
|
|
101
77
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `mcp-use` — MCP server framework on the official v2 SDK
|
|
2
|
+
* `mcp-use` — MCP server framework on the official v2 SDK, with a Hono HTTP
|
|
3
|
+
* application and a Web-standard Fetch serving boundary.
|
|
3
4
|
*
|
|
4
5
|
* Greenfield rebuild of the mcp-use server package against the stateless
|
|
5
6
|
* 2026-07-28 MCP protocol. See specs/SPEC.md for the phase plan and API contract.
|
|
6
7
|
*/
|
|
7
8
|
export { MCPServer } from "./server.js";
|
|
8
|
-
export type { ListenOptions
|
|
9
|
+
export type { ListenOptions } from "./server.js";
|
|
9
10
|
export { createMcpMount } from "./mount-mcp.js";
|
|
10
11
|
export type { MountMcpOptions, McpMount } from "./mount-mcp.js";
|
|
11
|
-
export { composeFetch, getRequestBag, hostValidationMiddleware, jsonBodyMiddleware, matchesPath, matchesPathPrefix, originValidationMiddleware, pathnameOf,
|
|
12
|
-
export type { FetchHandler, FetchMiddleware,
|
|
12
|
+
export { composeFetch, getRequestBag, hostValidationMiddleware, jsonBodyMiddleware, matchesPath, matchesPathPrefix, originValidationMiddleware, pathnameOf, } from "./fetch-app.js";
|
|
13
|
+
export type { FetchHandler, FetchMiddleware, RequestBag } from "./fetch-app.js";
|
|
13
14
|
export { registerViews } from "./views/index.js";
|
|
14
15
|
export { requestLogger } from "./logging.js";
|
|
15
16
|
export type { LoggingOptions, LogLevel } from "./logging.js";
|
|
16
17
|
export type { LandingPageOptions, LandingPagePrompt, LandingPageResource, LandingPageTool, } from "./landing.js";
|
|
17
18
|
/**
|
|
18
|
-
* Wire result shapes (re-exported from the SDK):
|
|
19
|
-
* shapes
|
|
20
|
-
* {@link ReadResourceResult}, prompts {@link GetPromptResult}.
|
|
21
|
-
*
|
|
19
|
+
* Wire result shapes (re-exported from the SDK): prefer returning these raw
|
|
20
|
+
* shapes from callbacks — tools {@link CallToolResult}, resources
|
|
21
|
+
* {@link ReadResourceResult}, prompts {@link GetPromptResult}. Deprecated
|
|
22
|
+
* response helpers (`text`, `object`, …) are thin shims that produce the same
|
|
23
|
+
* tool envelope; resource/prompt registration still converts helper-shaped
|
|
24
|
+
* returns for upgrade compatibility.
|
|
22
25
|
*/
|
|
23
26
|
export type { CallToolResult, ContentBlock, GetPromptResult, InputRequest, InputRequiredResult, InputResponses, PromptMessage, ReadResourceResult, } from "@modelcontextprotocol/server";
|
|
24
27
|
/**
|
|
@@ -55,4 +58,14 @@ export type { InferToolInput, InferToolName, InferToolOutput, ToolCallback, Tool
|
|
|
55
58
|
export type { ExternalViewManifestEntry, InlineViewManifestEntry, UiPermissions, ViewManifestEntry, ViewsManifest, } from "./views/index.js";
|
|
56
59
|
export type { InferTemplateParams, ResourceCallback, ResourceDefinition, ResourceTemplateCallback, ResourceTemplateCompleter, ResourceTemplateCompletions, ResourceTemplateDefinition, TemplateVariableValue, } from "./resources.js";
|
|
57
60
|
export type { InferPromptInput, PromptCallback, PromptDefinition, } from "./prompts.js";
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Prefer raw {@link CallToolResult} / {@link ReadResourceResult} /
|
|
63
|
+
* {@link GetPromptResult} returns. These helpers remain for upgrade
|
|
64
|
+
* compatibility and map to the official wire envelopes.
|
|
65
|
+
*/
|
|
66
|
+
export { array, audio, binary, css, error, html, image, javascript, markdown, mix, object, resource, text, widget, xml, } from "./response-helpers.js";
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated Prefer raw wire result types from the package root.
|
|
69
|
+
*/
|
|
70
|
+
export type { ToolContentResult, TypedCallToolResult, WidgetResponseConfig, } from "./response-helpers.js";
|
|
58
71
|
export type { ProxyConnection, ProxyHttpConfig, ProxyProgress, ProxyPrompt, ProxyRequestOptions, ProxyResource, ProxyServerConfig, ProxyTool, } from "./mcp-proxy.js";
|