mcp-use 2.0.0-beta.46 → 2.0.0-beta.47
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/bin.js +1 -1
- package/dist/chunk-4TTKTNKI.js +1 -0
- package/dist/{chunk-YGVMTVPK.js → chunk-MNSSFPOL.js} +1 -1
- package/dist/chunk-ZBN5QPYD.js +1 -0
- package/dist/compat-v1/oauth.d.ts +37 -0
- package/dist/compat-v1.d.ts +528 -0
- package/dist/compat-v1.js +35 -0
- package/dist/index.js +2 -2
- package/dist/internal/usage.js +1 -1
- package/dist/landing-handler-2IDA43KU.js +630 -0
- package/dist/mcp-proxy-O6GLK2IL.js +2 -0
- package/dist/node-bridge-KQ3STLK5.js +1 -0
- package/dist/public-route-GWDSKOSN.js +1 -0
- package/dist/react/compat-v1.d.ts +221 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.js +177 -5
- package/dist/react/runtime/view-runtime.d.ts +2 -0
- package/package.json +7 -3
package/dist/bin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var{main}=await import("@mcp-use/cli");main(process.argv.slice(2),{frameworkVersion:"2.0.0-beta.
|
|
2
|
+
var{main}=await import("@mcp-use/cli");main(process.argv.slice(2),{frameworkVersion:"2.0.0-beta.47"}).then(code=>{process.exitCode=code},error=>{console.error(error instanceof Error?error.message:String(error)),process.exitCode=1});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function d(e){return e.replace(/\/+$/,"")}function o(e){if(typeof process>"u")return;let n=process.env[e];return n!==void 0&&n!==""?n:void 0}function c(e){for(let n of e.split(",")){let t=new Map;for(let i of n.split(";")){let[u,...f]=i.trim().split("=");u===void 0||f.length===0||t.set(u.toLowerCase(),f.join("=").replace(/^"|"$/g,""))}let s=t.get("proto"),r=t.get("host");if(s!==void 0&&r!==void 0)return`${s}://${r}`}}function a(e){let n=e.headers.get("forwarded");if(n!==null){let r=c(n);if(r!==void 0)return r}let t=e.headers.get("x-forwarded-proto"),s=e.headers.get("x-forwarded-host");if(t!==null&&s!==null){let r=s.split(",")[0]?.trim(),i=t.split(",")[0]?.trim();if(r!==void 0&&i!==void 0&&r!=="")return`${i}://${r}`}return new URL(e.url).origin}function l(e){let n=o("MCP_URL");if(n!==void 0)try{return new URL(n).origin}catch{}return a(e)}function p(e){try{return new URL(e).origin}catch{return e}}function g(e){return d(e)}function h(e){let n=o("MCP_ASSETS_URL");if(n!==void 0)try{return g(new URL(n).href.replace(/\/$/,""))}catch{}return l(e)}function R(){let e=o("MCP_ASSETS_URL");if(e===void 0)return!1;try{return new URL(e),!0}catch{return!1}}export{l as a,p as b,h as c,R as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var EVENT="mcp_use_sdk_event",ENDPOINT="https://eu.i.posthog.com/i/v0/e/",TOKEN="phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI",CONTENT=/(^|_)(arguments?|args|body|command|headers?|location|message|organization|path|query|response|secret|subject|token|uri|url|user_agent)(_|$)/i,RESERVED=new Set("feature action sdk_generation telemetry_schema_version sdk_package sdk_version server_id runtime_id identity_stability distinct_id validation_run_id is_validation".split(" ")),runtimeId=crypto.randomUUID(),once=new Set,pending=new Set,identities=new Map;function hasControl(value){return[...value].some(character=>{let code=character.charCodeAt(0);return code<32||code===127})}function env(name){return typeof process>"u"?void 0:process.env?.[name]}function safeEnv(name){let value=env(name);return value!==void 0&&value.length>0&&value.length<=128&&!hasControl(value)?value:void 0}function disabled(){if(env("MCP_USE_ANONYMIZED_TELEMETRY")==="false")return!0;try{return globalThis.__MCP_USE_ANONYMIZED_TELEMETRY__===!1||typeof localStorage<"u"&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false"}catch{return!1}}function clean(properties){return Object.fromEntries(Object.entries(properties).filter(([key,value])=>key.length>128||hasControl(key)||key.startsWith("$")||RESERVED.has(key)||CONTENT.test(key)||value===void 0?!1:typeof value=="string"?value.length<=128&&!hasControl(value):typeof value=="boolean"||typeof value=="number"&&Number.isFinite(value)))}async function identity(serverRoot){let projectId=safeEnv("MCP_USE_TELEMETRY_PROJECT_ID");if(projectId!==void 0)return{id:projectId,stability:"project"};if(serverRoot===void 0||typeof process>"u")return{id:runtimeId,stability:"process"};let existing=identities.get(serverRoot);if(existing!==void 0)return existing;let resolving=(async()=>{try{let fs=await import("fs/promises"),directory=`${serverRoot}/.mcp-use`,file=`${directory}/usage.json`,read=async()=>{try{let value=JSON.parse(await fs.readFile(file,"utf8"));if(typeof value=="object"&&value!==null&&"schemaVersion"in value&&value.schemaVersion===1&&"serverId"in value&&typeof value.serverId=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value.serverId))return value.serverId}catch{}},stored=await read();if(stored!==void 0)return{id:stored,stability:"server"};await fs.mkdir(directory,{recursive:!0,mode:448});let created=crypto.randomUUID();try{return await fs.writeFile(file,`${JSON.stringify({schemaVersion:1,serverId:created})}
|
|
2
|
-
`,{flag:"wx",mode:384}),{id:created,stability:"server"}}catch{let raced=await read();if(raced!==void 0)return{id:raced,stability:"server"}}}catch{}return{id:runtimeId,stability:"process"}})();return identities.set(serverRoot,resolving),resolving}function capture(feature,action,properties,options,resolveIdentity){let validationId=safeEnv("MCP_USE_TELEMETRY_VALIDATION_ID");if(disabled()||env("NODE_ENV")==="test"&&validationId===void 0||pending.size>=16)return;if(options.onceKey!==void 0){if(once.has(options.onceKey))return;once.add(options.onceKey)}let rate=Math.max(0,Math.min(1,options.sampleRate??1));if(validationId===void 0&&Math.random()>=rate)return;let request=(async()=>{try{let resolvedIdentity=await resolveIdentity(),body=JSON.stringify({api_key:TOKEN,event:EVENT,properties:{...clean(properties),feature,action,sdk_generation:"v2",telemetry_schema_version:2,sdk_package:"mcp-use",sdk_version:"2.0.0-beta.
|
|
2
|
+
`,{flag:"wx",mode:384}),{id:created,stability:"server"}}catch{let raced=await read();if(raced!==void 0)return{id:raced,stability:"server"}}}catch{}return{id:runtimeId,stability:"process"}})();return identities.set(serverRoot,resolving),resolving}function capture(feature,action,properties,options,resolveIdentity){let validationId=safeEnv("MCP_USE_TELEMETRY_VALIDATION_ID");if(disabled()||env("NODE_ENV")==="test"&&validationId===void 0||pending.size>=16)return;if(options.onceKey!==void 0){if(once.has(options.onceKey))return;once.add(options.onceKey)}let rate=Math.max(0,Math.min(1,options.sampleRate??1));if(validationId===void 0&&Math.random()>=rate)return;let request=(async()=>{try{let resolvedIdentity=await resolveIdentity(),body=JSON.stringify({api_key:TOKEN,event:EVENT,properties:{...clean(properties),feature,action,sdk_generation:"v2",telemetry_schema_version:2,sdk_package:"mcp-use",sdk_version:"2.0.0-beta.47",server_id:resolvedIdentity.id,runtime_id:runtimeId,identity_stability:resolvedIdentity.stability,distinct_id:resolvedIdentity.id,sample_rate:validationId===void 0?rate:1,$process_person_profile:!1,$geoip_disable:!0,...validationId!==void 0&&{is_validation:!0,validation_run_id:validationId}}});await fetch(ENDPOINT,{method:"POST",headers:{"content-type":"application/json"},keepalive:!0,body})}catch{return}})();pending.add(request),request.then(()=>pending.delete(request))}function recordUsage(feature,action,properties={},options={}){capture(feature,action,properties,options,()=>identity(options.serverRoot))}async function flushUsage(){await Promise.all([...pending])}export{recordUsage,flushUsage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c={".css":"text/css",".gif":"image/gif",".html":"text/html",".ico":"image/x-icon",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"application/javascript",".json":"application/json",".map":"application/json",".png":"image/png",".svg":"image/svg+xml",".txt":"text/plain",".webp":"image/webp",".woff":"font/woff",".woff2":"font/woff2"};async function p(i,t){let{stat:r}=await import("fs/promises"),{resolve:o,sep:a}=await import("path");if(t===""||t.includes("\\")||t.split("/").some(l=>l===".."))return null;let e=t.replace(/^\/+/,"");if(e===""||e.endsWith("/"))return null;let n=o(i),s=o(n,e);if(s!==n&&!s.startsWith(n+a))return null;try{if(!(await r(s)).isFile())return null}catch{return null}return s}async function g(i,t={}){let{readFile:r}=await import("fs/promises"),{extname:o}=await import("path"),a=o(i).toLowerCase(),e=c[a]??"application/octet-stream",n=t.head===!0?null:new Uint8Array(await r(i));return new Response(n,{status:200,headers:{"Content-Type":e,"Cache-Control":"public, max-age=0, must-revalidate",...t.deferCors!==!0&&{"Access-Control-Allow-Origin":"*"}}})}export{p as a,g as b};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1 OAuth provider factories with legacy env fallbacks.
|
|
3
|
+
*
|
|
4
|
+
* @deprecated Import from `mcp-use/oauth/*`. Removed in mcp-use v3.
|
|
5
|
+
*/
|
|
6
|
+
import { type Auth0OAuthProviderOptions } from "../oauth/auth0.js";
|
|
7
|
+
import { type BetterAuthOAuthProviderOptions } from "../oauth/better-auth.js";
|
|
8
|
+
import { type ClerkOAuthProviderOptions } from "../oauth/clerk.js";
|
|
9
|
+
import { type KeycloakOAuthProviderOptions } from "../oauth/keycloak.js";
|
|
10
|
+
import type { OAuthProvider } from "../oauth/provider.js";
|
|
11
|
+
import { type SupabaseOAuthProviderOptions } from "../oauth/supabase.js";
|
|
12
|
+
import { type WorkOSOAuthProviderOptions } from "../oauth/workos.js";
|
|
13
|
+
/** @deprecated Removed in mcp-use v3. */
|
|
14
|
+
export declare function oauthSupabaseProvider(options?: Partial<SupabaseOAuthProviderOptions>): OAuthProvider<unknown>;
|
|
15
|
+
/** @deprecated Removed in mcp-use v3. */
|
|
16
|
+
export declare function oauthAuth0Provider(options?: Partial<Auth0OAuthProviderOptions> & {
|
|
17
|
+
audience?: string;
|
|
18
|
+
verifyJwt?: boolean;
|
|
19
|
+
}): OAuthProvider<unknown>;
|
|
20
|
+
/** @deprecated Removed in mcp-use v3. */
|
|
21
|
+
export declare function oauthKeycloakProvider(options?: Partial<KeycloakOAuthProviderOptions> & {
|
|
22
|
+
audience?: string;
|
|
23
|
+
verifyJwt?: boolean;
|
|
24
|
+
}): OAuthProvider<unknown>;
|
|
25
|
+
/** @deprecated Removed in mcp-use v3. */
|
|
26
|
+
export declare function oauthWorkOSProvider(options?: Partial<WorkOSOAuthProviderOptions> & {
|
|
27
|
+
verifyJwt?: boolean;
|
|
28
|
+
}): OAuthProvider<unknown>;
|
|
29
|
+
/** @deprecated Removed in mcp-use v3. */
|
|
30
|
+
export declare function oauthClerkProvider(options?: Partial<ClerkOAuthProviderOptions> & {
|
|
31
|
+
audience?: string;
|
|
32
|
+
verifyJwt?: boolean;
|
|
33
|
+
}): OAuthProvider<unknown>;
|
|
34
|
+
/** @deprecated Removed in mcp-use v3. */
|
|
35
|
+
export declare function oauthBetterAuthProvider(options?: Partial<BetterAuthOAuthProviderOptions> & {
|
|
36
|
+
verifyJwt?: boolean;
|
|
37
|
+
}): OAuthProvider<unknown>;
|
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deprecated v1 server compatibility entry.
|
|
3
|
+
*
|
|
4
|
+
* This file intentionally contains the complete server-side bridge. It
|
|
5
|
+
* normalizes the common v1 authoring shapes and delegates all protocol and
|
|
6
|
+
* HTTP behavior to the native v2 server.
|
|
7
|
+
*/
|
|
8
|
+
import type { CallToolResult, GetPromptResult, ReadResourceResult, StandardSchemaWithJSON } from "@modelcontextprotocol/server";
|
|
9
|
+
import type { Context, Env, Next } from "hono";
|
|
10
|
+
import type { ServerConfig as NativeServerConfig } from "./config.js";
|
|
11
|
+
import type { RequestContext, RequestClientContext } from "./context.js";
|
|
12
|
+
import type { FromOpenAPIOptions } from "./openapi/types.js";
|
|
13
|
+
import type { OAuthProvider } from "./oauth/provider.js";
|
|
14
|
+
import type { PromptDefinition as NativePromptDefinition } from "./prompts.js";
|
|
15
|
+
import { audio, binary, css, error, html, image, javascript, markdown, mix, object, resource, text, xml, type ToolContentResult, type TypedCallToolResult, type WidgetResponseConfig } from "./response-helpers.js";
|
|
16
|
+
import type { ResourceDefinition as NativeResourceDefinition, ResourceTemplateDefinition as NativeResourceTemplateDefinition } from "./resources.js";
|
|
17
|
+
import { MCPServer as NativeMCPServer } from "./server.js";
|
|
18
|
+
import type { ToolDefinition as NativeToolDefinition, ToolViewConfig } from "./tools.js";
|
|
19
|
+
import type { ViewsManifest } from "./views/types.js";
|
|
20
|
+
type UnknownRecord = Record<string, unknown>;
|
|
21
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Authenticated user shape exposed by the v1 callback context.
|
|
24
|
+
*
|
|
25
|
+
* @deprecated Temporary v1 compatibility. Native v2 providers expose their
|
|
26
|
+
* provider-specific user type at `ctx.auth.user`. Removed in mcp-use v3.
|
|
27
|
+
*/
|
|
28
|
+
export interface UserInfo extends UnknownRecord {
|
|
29
|
+
/** Stable v1 user identifier. */
|
|
30
|
+
userId: string;
|
|
31
|
+
/** Optional email claim. */
|
|
32
|
+
email?: string;
|
|
33
|
+
/** Optional display name. */
|
|
34
|
+
name?: string;
|
|
35
|
+
/** Optional role list. */
|
|
36
|
+
roles?: string[];
|
|
37
|
+
/** Optional permission list. */
|
|
38
|
+
permissions?: string[];
|
|
39
|
+
/** Optional scope list. */
|
|
40
|
+
scopes?: string[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Authentication data exposed by v1-compatible callbacks.
|
|
44
|
+
*
|
|
45
|
+
* @deprecated Use native v2 `OAuthAuth` from `mcp-use`. Removed in mcp-use v3.
|
|
46
|
+
*/
|
|
47
|
+
export interface AuthInfo {
|
|
48
|
+
/** Normalized legacy user object. */
|
|
49
|
+
user: UserInfo;
|
|
50
|
+
/** Verified token payload. */
|
|
51
|
+
payload: UnknownRecord;
|
|
52
|
+
/** Original bearer token. */
|
|
53
|
+
accessToken: string;
|
|
54
|
+
/** Granted scopes. */
|
|
55
|
+
scopes: string[];
|
|
56
|
+
/** Granted permissions. */
|
|
57
|
+
permissions: string[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* v1 client helpers plus the v1 `supportsApps()` spelling.
|
|
61
|
+
*
|
|
62
|
+
* @deprecated Use native v2 `RequestClientContext`; replace `supportsApps()`
|
|
63
|
+
* with `supportsViews()`. Removed in mcp-use v3.
|
|
64
|
+
*/
|
|
65
|
+
export interface ClientCapabilityChecker extends RequestClientContext {
|
|
66
|
+
/** Alias for native v2 `supportsViews()`. */
|
|
67
|
+
supportsApps(): boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Common v1 callback context translated onto the request-scoped v2 context.
|
|
71
|
+
* Session-backed sampling and blocking elicitation are intentionally absent.
|
|
72
|
+
*
|
|
73
|
+
* @deprecated Use native v2 `RequestContext` from `mcp-use`. Removed in
|
|
74
|
+
* mcp-use v3.
|
|
75
|
+
*/
|
|
76
|
+
export type McpContext<_HasOAuth extends boolean = false> = Omit<RequestContext<never, false>, "auth" | "client"> & {
|
|
77
|
+
/** v1-compatible client metadata helpers. */
|
|
78
|
+
client: ClientCapabilityChecker;
|
|
79
|
+
/** v1 name for native v2 `sendLog()`. */
|
|
80
|
+
log(level: "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency", data: unknown, logger?: string): Promise<void>;
|
|
81
|
+
} & {
|
|
82
|
+
/**
|
|
83
|
+
* v1 authentication context. The compatibility entry keeps this
|
|
84
|
+
* non-optional because the v1 constructor inferred OAuth from
|
|
85
|
+
* `config.oauth`; callbacks still only receive it when OAuth is configured.
|
|
86
|
+
*/
|
|
87
|
+
auth: AuthInfo;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Common v1 CORS option names.
|
|
91
|
+
*
|
|
92
|
+
* @deprecated Use `CorsOptions` from `mcp-use`. Removed in mcp-use v3.
|
|
93
|
+
*/
|
|
94
|
+
export interface CorsOptions {
|
|
95
|
+
/** Allowed response origin or origins. */
|
|
96
|
+
origin?: string | string[];
|
|
97
|
+
/** v1 spelling for allowed HTTP methods. */
|
|
98
|
+
allowMethods?: string[];
|
|
99
|
+
/** v1 spelling for allowed request headers. */
|
|
100
|
+
allowHeaders?: string[];
|
|
101
|
+
/** Whether credentials are allowed. */
|
|
102
|
+
credentials?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Common v1 constructor configuration supported by the temporary bridge.
|
|
106
|
+
*
|
|
107
|
+
* @deprecated Use `ServerConfig` from `mcp-use`. Removed in mcp-use v3.
|
|
108
|
+
*/
|
|
109
|
+
export interface ServerConfig {
|
|
110
|
+
/** Server implementation name. */
|
|
111
|
+
name: string;
|
|
112
|
+
/** Server implementation version. */
|
|
113
|
+
version: string;
|
|
114
|
+
/** Display title. */
|
|
115
|
+
title?: string;
|
|
116
|
+
/** Server description. */
|
|
117
|
+
description?: string;
|
|
118
|
+
/** Model-facing server instructions. */
|
|
119
|
+
instructions?: string;
|
|
120
|
+
/** Node listener host. */
|
|
121
|
+
host?: string;
|
|
122
|
+
/** Node listener port. */
|
|
123
|
+
port?: number;
|
|
124
|
+
/** Public v1 server URL. */
|
|
125
|
+
baseUrl?: string;
|
|
126
|
+
/** v1 Host allowlist despite the historical option name. */
|
|
127
|
+
allowedOrigins?: string[];
|
|
128
|
+
/** v1 CORS configuration. */
|
|
129
|
+
cors?: CorsOptions;
|
|
130
|
+
/** Stateless mode is accepted only when true. */
|
|
131
|
+
stateless?: boolean;
|
|
132
|
+
/** Unsupported v1 session idle timeout. */
|
|
133
|
+
sessionIdleTimeoutMs?: number;
|
|
134
|
+
/** Unsupported v1 stale-session behavior. */
|
|
135
|
+
autoCreateSessionOnInvalidId?: boolean;
|
|
136
|
+
/** Unsupported v1 session storage. */
|
|
137
|
+
sessionStore?: unknown;
|
|
138
|
+
/** Unsupported v1 stream manager. */
|
|
139
|
+
streamManager?: unknown;
|
|
140
|
+
/** Built-in external OAuth resource-server provider. */
|
|
141
|
+
oauth?: OAuthProvider<unknown>;
|
|
142
|
+
/** Whether the landing page is public with OAuth enabled. */
|
|
143
|
+
publicLandingPage?: boolean;
|
|
144
|
+
/** Browser favicon. */
|
|
145
|
+
favicon?: string;
|
|
146
|
+
/** Server icons. */
|
|
147
|
+
icons?: NativeServerConfig["icons"];
|
|
148
|
+
/** Server website. */
|
|
149
|
+
websiteUrl?: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* v1 tool-to-widget binding.
|
|
153
|
+
*
|
|
154
|
+
* @deprecated Use native v2 `view` from `mcp-use`. Removed in mcp-use v3.
|
|
155
|
+
*/
|
|
156
|
+
export interface ToolWidgetConfig {
|
|
157
|
+
/** Legacy widget directory name. */
|
|
158
|
+
name: string;
|
|
159
|
+
/** Invocation status text. */
|
|
160
|
+
invoking?: string;
|
|
161
|
+
/** Completion status text. */
|
|
162
|
+
invoked?: string;
|
|
163
|
+
/** Whether the widget may call tools. */
|
|
164
|
+
widgetAccessible?: boolean;
|
|
165
|
+
/** Whether the result can open the widget. */
|
|
166
|
+
resultCanProduceWidget?: boolean;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Common v1 tool definition.
|
|
170
|
+
*
|
|
171
|
+
* @deprecated Use native v2 `ToolDefinition` and pass the callback separately.
|
|
172
|
+
* Removed in mcp-use v3.
|
|
173
|
+
*/
|
|
174
|
+
export interface ToolDefinition<TInput = UnknownRecord, TOutput = UnknownRecord, HasOAuth extends boolean = false> extends Omit<NativeToolDefinition, "inputSchema" | "view"> {
|
|
175
|
+
/** Zod/Standard Schema input definition. */
|
|
176
|
+
schema?: StandardSchemaWithJSON;
|
|
177
|
+
/** Unsupported legacy array schema. */
|
|
178
|
+
inputs?: unknown[];
|
|
179
|
+
/** Optional inline callback. */
|
|
180
|
+
cb?: ToolCallback<TInput, TOutput, HasOAuth>;
|
|
181
|
+
/** Legacy widget binding. */
|
|
182
|
+
widget?: ToolWidgetConfig;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Common v1 tool callback.
|
|
186
|
+
*
|
|
187
|
+
* @deprecated Use native v2 `ToolCallback` from `mcp-use`. Removed in mcp-use
|
|
188
|
+
* v3.
|
|
189
|
+
*/
|
|
190
|
+
export type ToolCallback<TInput = UnknownRecord, TOutput = UnknownRecord, HasOAuth extends boolean = false> = (params: TInput, ctx: McpContext<HasOAuth>) => MaybePromise<CallToolResult | TypedCallToolResult<Extract<TOutput, UnknownRecord>> | ToolContentResult>;
|
|
191
|
+
/**
|
|
192
|
+
* Infer v1 tool input from its Standard Schema.
|
|
193
|
+
*
|
|
194
|
+
* @deprecated Use native v2 `InferToolInput`. Removed in mcp-use v3.
|
|
195
|
+
*/
|
|
196
|
+
export type InferToolInput<T> = T extends {
|
|
197
|
+
schema: infer S extends StandardSchemaWithJSON;
|
|
198
|
+
} ? StandardSchemaWithJSON.InferOutput<S> : UnknownRecord;
|
|
199
|
+
/**
|
|
200
|
+
* Infer v1 tool structured output from its Standard Schema.
|
|
201
|
+
*
|
|
202
|
+
* @deprecated Use native v2 `InferToolOutput`. Removed in mcp-use v3.
|
|
203
|
+
*/
|
|
204
|
+
export type InferToolOutput<T> = T extends {
|
|
205
|
+
outputSchema: infer S extends StandardSchemaWithJSON;
|
|
206
|
+
} ? StandardSchemaWithJSON.InferOutput<S> : UnknownRecord;
|
|
207
|
+
/**
|
|
208
|
+
* Common v1 static-resource definition.
|
|
209
|
+
*
|
|
210
|
+
* @deprecated Use native v2 `ResourceDefinition` and pass the reader
|
|
211
|
+
* separately. Removed in mcp-use v3.
|
|
212
|
+
*/
|
|
213
|
+
export interface ResourceDefinition<HasOAuth extends boolean = false> extends NativeResourceDefinition {
|
|
214
|
+
/** Optional inline v1 reader. */
|
|
215
|
+
readCallback?: ReadResourceCallback<HasOAuth>;
|
|
216
|
+
/** Legacy completion container; ignored for static resources. */
|
|
217
|
+
callbacks?: {
|
|
218
|
+
complete?: Record<string, unknown>;
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Common v1 static-resource callback. The first argument is context, not URI.
|
|
223
|
+
*
|
|
224
|
+
* @deprecated Use native v2 `ResourceCallback`. Removed in mcp-use v3.
|
|
225
|
+
*/
|
|
226
|
+
export type ReadResourceCallback<HasOAuth extends boolean = false> = (ctx: McpContext<HasOAuth>) => MaybePromise<ReadResourceResult | CallToolResult>;
|
|
227
|
+
/**
|
|
228
|
+
* v1 nested resource-template configuration.
|
|
229
|
+
*
|
|
230
|
+
* @deprecated Use native v2 `ResourceTemplateDefinition`. Removed in mcp-use
|
|
231
|
+
* v3.
|
|
232
|
+
*/
|
|
233
|
+
export interface ResourceTemplateConfig {
|
|
234
|
+
/** RFC 6570 URI template. */
|
|
235
|
+
uriTemplate: string;
|
|
236
|
+
/** Optional nested name. */
|
|
237
|
+
name?: string;
|
|
238
|
+
/** MIME type. */
|
|
239
|
+
mimeType?: string;
|
|
240
|
+
/** Description. */
|
|
241
|
+
description?: string;
|
|
242
|
+
/** Legacy completion callbacks. */
|
|
243
|
+
callbacks?: {
|
|
244
|
+
complete?: Record<string, unknown>;
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Common nested or flat v1 resource-template definition.
|
|
249
|
+
*
|
|
250
|
+
* @deprecated Use native v2 `ResourceTemplateDefinition`. Removed in mcp-use
|
|
251
|
+
* v3.
|
|
252
|
+
*/
|
|
253
|
+
export interface ResourceTemplateDefinition<HasOAuth extends boolean = false> {
|
|
254
|
+
/** Registration name. */
|
|
255
|
+
name: string;
|
|
256
|
+
/** Flat v1 URI-template form. */
|
|
257
|
+
uriTemplate?: string;
|
|
258
|
+
/** Nested v1 URI-template form. */
|
|
259
|
+
resourceTemplate?: ResourceTemplateConfig;
|
|
260
|
+
/** Optional title. */
|
|
261
|
+
title?: string;
|
|
262
|
+
/** Optional description. */
|
|
263
|
+
description?: string;
|
|
264
|
+
/** Optional MIME type. */
|
|
265
|
+
mimeType?: string;
|
|
266
|
+
/** Optional annotations. */
|
|
267
|
+
annotations?: NativeResourceTemplateDefinition["annotations"];
|
|
268
|
+
/** Optional descriptor metadata. */
|
|
269
|
+
_meta?: NativeResourceTemplateDefinition["_meta"];
|
|
270
|
+
/** Schema used only for v1 parameter inference. */
|
|
271
|
+
schema?: StandardSchemaWithJSON;
|
|
272
|
+
/** Legacy completion callbacks. */
|
|
273
|
+
callbacks?: {
|
|
274
|
+
complete?: Record<string, unknown>;
|
|
275
|
+
};
|
|
276
|
+
/** Optional inline reader. */
|
|
277
|
+
readCallback?: ReadResourceTemplateCallback<UnknownRecord, HasOAuth>;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Common v1 resource-template callback signatures.
|
|
281
|
+
*
|
|
282
|
+
* @deprecated Use native v2 `ResourceTemplateCallback`. Removed in mcp-use
|
|
283
|
+
* v3.
|
|
284
|
+
*/
|
|
285
|
+
export type ReadResourceTemplateCallback<TParams extends UnknownRecord = Record<string, string>, HasOAuth extends boolean = false> = (uri: URL, params: TParams, ctx: McpContext<HasOAuth>) => MaybePromise<ReadResourceResult | CallToolResult | TypedCallToolResult<UnknownRecord> | ToolContentResult>;
|
|
286
|
+
/** Infer v1 resource-template parameters from an optional Standard Schema. */
|
|
287
|
+
type InferResourceTemplateParams<T> = T extends {
|
|
288
|
+
schema: infer S extends StandardSchemaWithJSON;
|
|
289
|
+
} ? Extract<StandardSchemaWithJSON.InferOutput<S>, UnknownRecord> : Record<string, string>;
|
|
290
|
+
/**
|
|
291
|
+
* Common v1 prompt definition.
|
|
292
|
+
*
|
|
293
|
+
* @deprecated Use native v2 `PromptDefinition` and pass the callback
|
|
294
|
+
* separately. Removed in mcp-use v3.
|
|
295
|
+
*/
|
|
296
|
+
export interface PromptDefinition<TInput = UnknownRecord, HasOAuth extends boolean = false> extends NativePromptDefinition {
|
|
297
|
+
/** Unsupported legacy argument array. */
|
|
298
|
+
args?: unknown[];
|
|
299
|
+
/** Optional inline v1 callback. */
|
|
300
|
+
cb?: PromptCallback<TInput, HasOAuth>;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Common v1 prompt callback.
|
|
304
|
+
*
|
|
305
|
+
* @deprecated Use native v2 `PromptCallback`. Removed in mcp-use v3.
|
|
306
|
+
*/
|
|
307
|
+
export type PromptCallback<TInput = UnknownRecord, HasOAuth extends boolean = false> = (params: TInput, ctx: McpContext<HasOAuth>) => MaybePromise<GetPromptResult | CallToolResult>;
|
|
308
|
+
/**
|
|
309
|
+
* Infer v1 prompt input from its Standard Schema.
|
|
310
|
+
*
|
|
311
|
+
* @deprecated Use native v2 `InferPromptInput`. Removed in mcp-use v3.
|
|
312
|
+
*/
|
|
313
|
+
export type InferPromptInput<T> = T extends {
|
|
314
|
+
schema: infer S extends StandardSchemaWithJSON;
|
|
315
|
+
} ? StandardSchemaWithJSON.InferOutput<S> : UnknownRecord;
|
|
316
|
+
interface LegacyWidgetMetadata {
|
|
317
|
+
title?: string;
|
|
318
|
+
description?: string;
|
|
319
|
+
props?: StandardSchemaWithJSON | unknown[];
|
|
320
|
+
inputs?: StandardSchemaWithJSON | unknown[];
|
|
321
|
+
schema?: StandardSchemaWithJSON | unknown[];
|
|
322
|
+
toolOutput?: CallToolResult | ((params: UnknownRecord) => MaybePromise<CallToolResult>);
|
|
323
|
+
exposeAsTool?: boolean;
|
|
324
|
+
annotations?: NativeToolDefinition["annotations"];
|
|
325
|
+
_meta?: UnknownRecord;
|
|
326
|
+
metadata?: {
|
|
327
|
+
description?: string;
|
|
328
|
+
csp?: ToolViewConfig["csp"];
|
|
329
|
+
prefersBorder?: boolean;
|
|
330
|
+
domain?: string;
|
|
331
|
+
widgetDescription?: string;
|
|
332
|
+
autoResize?: boolean;
|
|
333
|
+
invoking?: string;
|
|
334
|
+
invoked?: string;
|
|
335
|
+
};
|
|
336
|
+
appsSdkMetadata?: {
|
|
337
|
+
"openai/widgetDescription"?: string;
|
|
338
|
+
"openai/widgetCSP"?: {
|
|
339
|
+
connect_domains?: string[];
|
|
340
|
+
resource_domains?: string[];
|
|
341
|
+
frame_domains?: string[];
|
|
342
|
+
};
|
|
343
|
+
"openai/widgetPrefersBorder"?: boolean;
|
|
344
|
+
"openai/widgetDomain"?: string;
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Temporary v1-compatible server facade backed by the native stateless v2
|
|
349
|
+
* server.
|
|
350
|
+
*
|
|
351
|
+
* @deprecated Temporary v1 compatibility. Import `MCPServer` from `mcp-use`.
|
|
352
|
+
* Removed in mcp-use v3.
|
|
353
|
+
*/
|
|
354
|
+
export declare class MCPServer<HasOAuth extends boolean = false, TEnv extends Env = Env> {
|
|
355
|
+
#private;
|
|
356
|
+
/** Original v1 configuration. */
|
|
357
|
+
readonly config: ServerConfig;
|
|
358
|
+
/** Native Hono application. */
|
|
359
|
+
readonly app: NativeMCPServer<unknown, TEnv>["app"];
|
|
360
|
+
/** Native Web-standard fetch handler. */
|
|
361
|
+
readonly fetch: NativeMCPServer<unknown, TEnv>["fetch"];
|
|
362
|
+
/** Native Hono GET route helper. */
|
|
363
|
+
readonly get: NativeMCPServer<unknown, TEnv>["get"];
|
|
364
|
+
/** Native Hono POST route helper. */
|
|
365
|
+
readonly post: NativeMCPServer<unknown, TEnv>["post"];
|
|
366
|
+
/** Native Hono PUT route helper. */
|
|
367
|
+
readonly put: NativeMCPServer<unknown, TEnv>["put"];
|
|
368
|
+
/** Native Hono PATCH route helper. */
|
|
369
|
+
readonly patch: NativeMCPServer<unknown, TEnv>["patch"];
|
|
370
|
+
/** Native Hono DELETE route helper. */
|
|
371
|
+
readonly delete: NativeMCPServer<unknown, TEnv>["delete"];
|
|
372
|
+
/** Native Hono all-method route helper. */
|
|
373
|
+
readonly all: NativeMCPServer<unknown, TEnv>["all"];
|
|
374
|
+
/** Native HTTP/MCP middleware registration. */
|
|
375
|
+
readonly use: NativeMCPServer<unknown, TEnv>["use"];
|
|
376
|
+
/** Native MCP observer registration. */
|
|
377
|
+
readonly on: NativeMCPServer<unknown, TEnv>["on"];
|
|
378
|
+
/** Configured listener host. */
|
|
379
|
+
readonly serverHost: string;
|
|
380
|
+
/** Actual listener port after standalone `listen()`. */
|
|
381
|
+
serverPort?: number;
|
|
382
|
+
/** Configured public URL. */
|
|
383
|
+
readonly serverBaseUrl?: string;
|
|
384
|
+
/**
|
|
385
|
+
* Create a v1-compatible facade.
|
|
386
|
+
*
|
|
387
|
+
* @param config - Common v1 server configuration.
|
|
388
|
+
*/
|
|
389
|
+
constructor(config: ServerConfig);
|
|
390
|
+
/**
|
|
391
|
+
* Create a v1-compatible server from an OpenAPI document.
|
|
392
|
+
*
|
|
393
|
+
* @deprecated Use native v2 `MCPServer.fromOpenAPI()` from `mcp-use`.
|
|
394
|
+
* Removed in mcp-use v3.
|
|
395
|
+
*/
|
|
396
|
+
static fromOpenAPI(options: FromOpenAPIOptions): MCPServer;
|
|
397
|
+
/** Native v2 MCP route path. */
|
|
398
|
+
get basePath(): string;
|
|
399
|
+
/** Configured native listener host. */
|
|
400
|
+
get host(): string | undefined;
|
|
401
|
+
/** Configured native listener port. */
|
|
402
|
+
get port(): number | undefined;
|
|
403
|
+
/** Native normalized branding. */
|
|
404
|
+
get branding(): NativeMCPServer<unknown, TEnv>["branding"];
|
|
405
|
+
/**
|
|
406
|
+
* Register a common v1 tool shape.
|
|
407
|
+
*
|
|
408
|
+
* @returns This facade for v1 method chaining.
|
|
409
|
+
*/
|
|
410
|
+
tool<T extends Omit<ToolDefinition, "cb">>(definition: T & {
|
|
411
|
+
cb: ToolCallback<InferToolInput<T>, InferToolOutput<T>, HasOAuth>;
|
|
412
|
+
}): this;
|
|
413
|
+
/** Register a common v1 tool with a separate callback. */
|
|
414
|
+
tool<T extends Omit<ToolDefinition, "cb">>(definition: T, callback: ToolCallback<InferToolInput<T>, InferToolOutput<T>, HasOAuth>): this;
|
|
415
|
+
/** Register a common v1 static resource. */
|
|
416
|
+
resource(definition: ResourceDefinition<HasOAuth>, callback?: ReadResourceCallback<HasOAuth>): this;
|
|
417
|
+
/** Register a common nested or flat v1 resource template. */
|
|
418
|
+
resourceTemplate<T extends Omit<ResourceTemplateDefinition<HasOAuth>, "readCallback">>(definition: T & {
|
|
419
|
+
readCallback: ReadResourceTemplateCallback<InferResourceTemplateParams<T>, HasOAuth>;
|
|
420
|
+
}): this;
|
|
421
|
+
resourceTemplate<T extends Omit<ResourceTemplateDefinition<HasOAuth>, "readCallback">>(definition: T, callback: ReadResourceTemplateCallback<InferResourceTemplateParams<T>, HasOAuth>): this;
|
|
422
|
+
/** Register a common v1 prompt shape. */
|
|
423
|
+
prompt<T extends Omit<PromptDefinition, "cb">>(definition: T & {
|
|
424
|
+
cb: PromptCallback<InferPromptInput<T>, HasOAuth>;
|
|
425
|
+
}): this;
|
|
426
|
+
/** Register a common v1 prompt with a separate callback. */
|
|
427
|
+
prompt<T extends Omit<PromptDefinition, "cb">>(definition: T, callback: PromptCallback<InferPromptInput<T>, HasOAuth>): this;
|
|
428
|
+
/**
|
|
429
|
+
* Start a standalone listener. Inside `mcp-use dev/build/start`, the call is
|
|
430
|
+
* captured because the CLI owns the listener.
|
|
431
|
+
*/
|
|
432
|
+
listen(port?: number, options?: Parameters<NativeMCPServer<unknown, TEnv>["listen"]>[1]): Promise<void | {
|
|
433
|
+
port: number;
|
|
434
|
+
url: string;
|
|
435
|
+
}>;
|
|
436
|
+
/** Close the native v2 server. */
|
|
437
|
+
close(): Promise<void>;
|
|
438
|
+
/** Deprecated v1 handler accessor backed by native `fetch`. */
|
|
439
|
+
getHandler(): typeof this.fetch;
|
|
440
|
+
/** Delegate supported HTTP upstream proxy registrations to v2. */
|
|
441
|
+
proxy(...args: Parameters<NativeMCPServer<unknown, TEnv>["proxy"]>): Promise<void>;
|
|
442
|
+
/** Delegate resource-update notifications to v2. */
|
|
443
|
+
notifyResourceUpdated(uri: string): Promise<void>;
|
|
444
|
+
/** @internal Called by the v2 CLI before view priming. */
|
|
445
|
+
__registerLegacyViews(widgets: Record<string, {
|
|
446
|
+
widgetMetadata?: LegacyWidgetMetadata;
|
|
447
|
+
}>): void;
|
|
448
|
+
/** @internal Prime the native view manifest after legacy metadata loading. */
|
|
449
|
+
__primeViews(views: ViewsManifest, options?: {
|
|
450
|
+
dev?: boolean;
|
|
451
|
+
projectRoot?: string;
|
|
452
|
+
}): void;
|
|
453
|
+
/** @internal Mount and validate the native v2 application. */
|
|
454
|
+
__mount(): void;
|
|
455
|
+
/** @internal Attach the CLI development event bus. */
|
|
456
|
+
__setEventBus(bus: Parameters<NativeMCPServer<unknown, TEnv>["__setEventBus"]>[0]): void;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Create a v1-compatible server using the old name-plus-config factory.
|
|
460
|
+
*
|
|
461
|
+
* @deprecated Use `new MCPServer(...)` from `mcp-use`. Removed in mcp-use v3.
|
|
462
|
+
*/
|
|
463
|
+
export declare function createMCPServer(name: string, config?: Partial<ServerConfig>): MCPServer;
|
|
464
|
+
/**
|
|
465
|
+
* v1 array helper preserving `structuredContent: { data }`.
|
|
466
|
+
*
|
|
467
|
+
* @deprecated Return a raw v2 tool result. Removed in mcp-use v3.
|
|
468
|
+
*/
|
|
469
|
+
export declare function array<T extends unknown[]>(data: T): CallToolResult;
|
|
470
|
+
/**
|
|
471
|
+
* v1 widget helper that always emits an object `structuredContent` value.
|
|
472
|
+
*
|
|
473
|
+
* @deprecated Register a native v2 `view` and return a raw result. Removed in
|
|
474
|
+
* mcp-use v3.
|
|
475
|
+
*/
|
|
476
|
+
export declare function widget<TProps extends UnknownRecord = UnknownRecord>(config: WidgetResponseConfig<TProps>): TypedCallToolResult<TProps>;
|
|
477
|
+
/** @deprecated Import `text` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
478
|
+
export { text };
|
|
479
|
+
/** @deprecated Import `markdown` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
480
|
+
export { markdown };
|
|
481
|
+
/** @deprecated Import `html` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
482
|
+
export { html };
|
|
483
|
+
/** @deprecated Import `xml` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
484
|
+
export { xml };
|
|
485
|
+
/** @deprecated Import `css` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
486
|
+
export { css };
|
|
487
|
+
/** @deprecated Import `javascript` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
488
|
+
export { javascript };
|
|
489
|
+
/** @deprecated Import `object` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
490
|
+
export { object };
|
|
491
|
+
/** @deprecated Import `image` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
492
|
+
export { image };
|
|
493
|
+
/** @deprecated Import `audio` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
494
|
+
export { audio };
|
|
495
|
+
/** @deprecated Import `binary` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
496
|
+
export { binary };
|
|
497
|
+
/** @deprecated Import `resource` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
498
|
+
export { resource };
|
|
499
|
+
/** @deprecated Import `mix` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
500
|
+
export { mix };
|
|
501
|
+
/** @deprecated Import `error` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
502
|
+
export { error };
|
|
503
|
+
/** @deprecated Import `completable` from `mcp-use` only while migrating. Removed in mcp-use v3. */
|
|
504
|
+
export { completable } from "./completable.js";
|
|
505
|
+
/** @deprecated Use raw v2 result types from `mcp-use`. Removed in mcp-use v3. */
|
|
506
|
+
export type { ToolContentResult, TypedCallToolResult, WidgetResponseConfig };
|
|
507
|
+
/** @deprecated Use raw SDK result types from `mcp-use`. Removed in mcp-use v3. */
|
|
508
|
+
export type { CallToolResult, GetPromptResult, ReadResourceResult };
|
|
509
|
+
/** @deprecated Use native v2 OpenAPI types from `mcp-use`. Removed in mcp-use v3. */
|
|
510
|
+
export type { FromOpenAPIOptions, OpenAPIAuth, OpenAPIDocument, OpenAPIExcludeRule, } from "./openapi/types.js";
|
|
511
|
+
/** @deprecated Import from `mcp-use/oauth/*`. Removed in mcp-use v3. */
|
|
512
|
+
export { oauthAuth0Provider, oauthBetterAuthProvider, oauthClerkProvider, oauthKeycloakProvider, oauthSupabaseProvider, oauthWorkOSProvider, } from "./compat-v1/oauth.js";
|
|
513
|
+
/** @deprecated Use native v2 middleware types from `mcp-use`. Removed in mcp-use v3. */
|
|
514
|
+
export type { McpMiddlewareFn, McpMiddlewareFnFor, McpMiddlewarePattern, MiddlewareContext, } from "./middleware/mcp-middleware.js";
|
|
515
|
+
/**
|
|
516
|
+
* Read v1-compatible authentication data from a tool or Hono context.
|
|
517
|
+
*
|
|
518
|
+
* @deprecated Read `ctx.auth` directly in native v2. Removed in mcp-use v3.
|
|
519
|
+
*/
|
|
520
|
+
export declare function getAuth(context: McpContext<boolean> | Context): AuthInfo;
|
|
521
|
+
/** @deprecated Check `ctx.auth.scopes` in native v2. Removed in mcp-use v3. */
|
|
522
|
+
export declare function hasScope(context: McpContext<boolean> | Context, needed: string | string[]): boolean;
|
|
523
|
+
/** @deprecated Check `ctx.auth.scopes` in native v2. Removed in mcp-use v3. */
|
|
524
|
+
export declare function hasAnyScope(context: McpContext<boolean> | Context, needed: string[]): boolean;
|
|
525
|
+
/** @deprecated Write native v2 Hono middleware. Removed in mcp-use v3. */
|
|
526
|
+
export declare function requireScope(needed: string | string[]): (context: Context, next: Next) => Promise<Response | void>;
|
|
527
|
+
/** @deprecated Write native v2 Hono middleware. Removed in mcp-use v3. */
|
|
528
|
+
export declare function requireAnyScope(needed: string[]): (context: Context, next: Next) => Promise<Response | void>;
|