mcp-use 1.0.4 → 1.0.6
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/README.md +98 -1
- package/dist/index.cjs +118 -689
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +118 -54
- package/dist/src/agents/mcp_agent.d.ts +1 -1
- package/dist/src/agents/mcp_agent.d.ts.map +1 -1
- package/dist/src/server/adapters/mcp-ui-adapter.d.ts +66 -0
- package/dist/src/server/adapters/mcp-ui-adapter.d.ts.map +1 -0
- package/dist/src/server/index.cjs +292 -14
- package/dist/src/server/index.d.ts +4 -2
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/index.js +913 -4
- package/dist/src/server/mcp-server.d.ts +91 -2
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/types/common.d.ts +27 -0
- package/dist/src/server/types/common.d.ts.map +1 -0
- package/dist/src/server/types/index.d.ts +8 -0
- package/dist/src/server/types/index.d.ts.map +1 -0
- package/dist/src/server/types/prompt.d.ts +14 -0
- package/dist/src/server/types/prompt.d.ts.map +1 -0
- package/dist/src/server/types/resource.d.ts +155 -0
- package/dist/src/server/types/resource.d.ts.map +1 -0
- package/dist/src/server/types/tool.d.ts +14 -0
- package/dist/src/server/types/tool.d.ts.map +1 -0
- package/dist/src/server/types.d.ts +3 -76
- package/dist/src/server/types.d.ts.map +1 -1
- package/dist/tests/helpers/widget-generators.d.ts +24 -0
- package/dist/tests/helpers/widget-generators.d.ts.map +1 -0
- package/dist/tests/mcp-ui-adapter.test.d.ts +8 -0
- package/dist/tests/mcp-ui-adapter.test.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -36
- package/dist/chunk-MZPKOZE4.js +0 -644
package/dist/index.d.ts
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* Main package exports for MCP client and MCP agent functionality
|
3
|
+
*
|
4
|
+
* This file serves as the primary entry point for consuming MCP (Model Context Protocol)
|
5
|
+
* functionality in client applications and agent implementations. It exports all necessary
|
6
|
+
* classes, utilities, and types for building MCP-based applications.
|
7
|
+
*
|
8
|
+
* @important Server functionality is exported from ./src/server/index.js -
|
9
|
+
* do NOT export server-related modules from this file.
|
10
|
+
*/
|
1
11
|
import { MCPAgent } from './src/agents/mcp_agent.js';
|
2
12
|
import { RemoteAgent } from './src/agents/remote.js';
|
3
13
|
import { MCPClient } from './src/client.js';
|
@@ -13,8 +23,6 @@ export * from './src/agents/utils/index.js';
|
|
13
23
|
export { ServerManager } from './src/managers/server_manager.js';
|
14
24
|
export * from './src/managers/tools/index.js';
|
15
25
|
export { type ObservabilityConfig, ObservabilityManager } from './src/observability/index.js';
|
16
|
-
export { createMCPServer } from './src/server/index.js';
|
17
|
-
export type { InputDefinition, PromptDefinition, PromptHandler, ResourceDefinition, ResourceHandler, ServerConfig, ToolDefinition, ToolHandler, } from './src/server/types.js';
|
18
26
|
export { setTelemetrySource, Telemetry } from './src/telemetry/index.js';
|
19
27
|
export { OAuthHelper, LINEAR_OAUTH_CONFIG, createOAuthMCPConfig } from './src/oauth-helper.js';
|
20
28
|
export type { OAuthConfig, OAuthDiscovery, ClientRegistration, OAuthResult, OAuthState } from './src/oauth-helper.js';
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,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AAA;AAEhE,cAAc,+BAA+B,CAAA;AAG7C,OAAO,EAAE,KAAK,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAG7F,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAGxE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAC9F,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAGrH,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACpF,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAGtD,cAAc,sBAAsB,CAAA;AAGpC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAG3G,YAAY,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAErE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAA"}
|
package/dist/index.js
CHANGED
@@ -5,9 +5,6 @@ import {
|
|
5
5
|
BrowserOAuthClientProvider,
|
6
6
|
onMcpAuthorization
|
7
7
|
} from "./chunk-TJXUCAST.js";
|
8
|
-
import {
|
9
|
-
createMCPServer
|
10
|
-
} from "./chunk-MZPKOZE4.js";
|
11
8
|
import {
|
12
9
|
Logger,
|
13
10
|
logger
|
@@ -1776,7 +1773,8 @@ var MCPAgent = class {
|
|
1776
1773
|
const startTime = Date.now();
|
1777
1774
|
const toolsUsedNames = [];
|
1778
1775
|
let stepsTaken = 0;
|
1779
|
-
|
1776
|
+
const structuredOutputSuccess = false;
|
1777
|
+
const structuredOutputSuccessRef = { value: structuredOutputSuccess };
|
1780
1778
|
let structuredLlm = null;
|
1781
1779
|
let schemaDescription = "";
|
1782
1780
|
if (outputSchema) {
|
@@ -1866,28 +1864,26 @@ var MCPAgent = class {
|
|
1866
1864
|
result = nextStepOutput.returnValues?.output ?? "No output generated";
|
1867
1865
|
runManager?.handleChainEnd({ output: result });
|
1868
1866
|
if (outputSchema && structuredLlm) {
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
);
|
1877
|
-
logger.debug(`\u{1F504} Structured result: ${JSON.stringify(structuredResult)}`);
|
1867
|
+
logger.info("\u{1F527} Attempting structured output...");
|
1868
|
+
const currentResult = result;
|
1869
|
+
this._attemptStructuredOutput(
|
1870
|
+
currentResult,
|
1871
|
+
this.llm,
|
1872
|
+
outputSchema
|
1873
|
+
).then((structuredResult) => {
|
1878
1874
|
if (this.memoryEnabled) {
|
1879
1875
|
this.addToHistory(new AIMessage(`Structured result: ${JSON.stringify(structuredResult)}`));
|
1880
1876
|
}
|
1881
1877
|
logger.info("\u2705 Structured output successful");
|
1882
|
-
|
1878
|
+
structuredOutputSuccessRef.value = true;
|
1883
1879
|
return structuredResult;
|
1884
|
-
}
|
1880
|
+
}).catch((e) => {
|
1885
1881
|
logger.warn(`\u26A0\uFE0F Structured output failed: ${e}`);
|
1886
1882
|
const failedStructuredOutputPrompt = `
|
1887
1883
|
The current result cannot be formatted into the required structure.
|
1888
1884
|
Error: ${String(e)}
|
1889
1885
|
|
1890
|
-
Current information: ${
|
1886
|
+
Current information: ${currentResult}
|
1891
1887
|
|
1892
1888
|
If information is missing, please continue working to gather the missing information needed for:
|
1893
1889
|
${schemaDescription}
|
@@ -1899,36 +1895,35 @@ var MCPAgent = class {
|
|
1899
1895
|
this.addToHistory(new HumanMessage(failedStructuredOutputPrompt));
|
1900
1896
|
}
|
1901
1897
|
logger.info("\u{1F504} Continuing execution to gather missing information...");
|
1902
|
-
|
1903
|
-
}
|
1904
|
-
} else {
|
1905
|
-
break;
|
1898
|
+
});
|
1906
1899
|
}
|
1907
1900
|
}
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1901
|
+
if (Array.isArray(nextStepOutput)) {
|
1902
|
+
const stepArray = nextStepOutput;
|
1903
|
+
intermediateSteps.push(...stepArray);
|
1904
|
+
for (const step of stepArray) {
|
1905
|
+
yield step;
|
1906
|
+
const { action, observation } = step;
|
1907
|
+
const toolName = action.tool;
|
1908
|
+
toolsUsedNames.push(toolName);
|
1909
|
+
let toolInputStr = typeof action.toolInput === "string" ? action.toolInput : JSON.stringify(action.toolInput, null, 2);
|
1910
|
+
if (toolInputStr.length > 100)
|
1911
|
+
toolInputStr = `${toolInputStr.slice(0, 97)}...`;
|
1912
|
+
logger.info(`\u{1F527} Tool call: ${toolName} with input: ${toolInputStr}`);
|
1913
|
+
let outputStr = String(observation);
|
1914
|
+
if (outputStr.length > 100)
|
1915
|
+
outputStr = `${outputStr.slice(0, 97)}...`;
|
1916
|
+
outputStr = outputStr.replace(/\n/g, " ");
|
1917
|
+
logger.info(`\u{1F4C4} Tool result: ${outputStr}`);
|
1918
|
+
}
|
1919
|
+
if (stepArray.length) {
|
1920
|
+
const lastStep = stepArray[stepArray.length - 1];
|
1921
|
+
const toolReturn = await this._agentExecutor._getToolReturn(lastStep);
|
1922
|
+
if (toolReturn) {
|
1923
|
+
logger.info(`\u{1F3C6} Tool returned directly at step ${stepNum + 1}`);
|
1924
|
+
result = toolReturn.returnValues?.output ?? "No output generated";
|
1925
|
+
break;
|
1926
|
+
}
|
1932
1927
|
}
|
1933
1928
|
}
|
1934
1929
|
} catch (e) {
|
@@ -1951,7 +1946,7 @@ var MCPAgent = class {
|
|
1951
1946
|
runManager?.handleChainEnd({ output: result });
|
1952
1947
|
}
|
1953
1948
|
logger.info("\u{1F389} Agent execution complete");
|
1954
|
-
|
1949
|
+
structuredOutputSuccessRef.value = true;
|
1955
1950
|
return result;
|
1956
1951
|
} catch (e) {
|
1957
1952
|
logger.error(`\u274C Error running query: ${e}`);
|
@@ -1972,7 +1967,7 @@ var MCPAgent = class {
|
|
1972
1967
|
await this.telemetry.trackAgentExecution({
|
1973
1968
|
executionMethod: "stream",
|
1974
1969
|
query,
|
1975
|
-
success,
|
1970
|
+
success: structuredOutputSuccess,
|
1976
1971
|
modelProvider: this.modelProvider,
|
1977
1972
|
modelName: this.modelName,
|
1978
1973
|
serverCount,
|
@@ -1990,7 +1985,7 @@ var MCPAgent = class {
|
|
1990
1985
|
toolsUsedNames,
|
1991
1986
|
response: result,
|
1992
1987
|
executionTimeMs,
|
1993
|
-
errorType:
|
1988
|
+
errorType: structuredOutputSuccess ? null : "execution_error",
|
1994
1989
|
conversationHistoryLength
|
1995
1990
|
});
|
1996
1991
|
if (manageConnector && !this.client && initializedHere) {
|
@@ -2031,13 +2026,16 @@ var MCPAgent = class {
|
|
2031
2026
|
* Yields LangChain StreamEvent objects from the underlying streamEvents() method.
|
2032
2027
|
* This provides token-level streaming and fine-grained event updates.
|
2033
2028
|
*/
|
2034
|
-
async *streamEvents(query, maxSteps, manageConnector = true, externalHistory) {
|
2029
|
+
async *streamEvents(query, maxSteps, manageConnector = true, externalHistory, outputSchema) {
|
2035
2030
|
let initializedHere = false;
|
2036
2031
|
const startTime = Date.now();
|
2037
2032
|
let success = false;
|
2038
2033
|
let eventCount = 0;
|
2039
2034
|
let totalResponseLength = 0;
|
2040
2035
|
let finalResponse = "";
|
2036
|
+
if (outputSchema) {
|
2037
|
+
query = this._enhanceQueryWithSchema(query, outputSchema);
|
2038
|
+
}
|
2041
2039
|
try {
|
2042
2040
|
if (manageConnector && !this._initialized) {
|
2043
2041
|
await this.initialize();
|
@@ -2085,15 +2083,71 @@ var MCPAgent = class {
|
|
2085
2083
|
totalResponseLength += event.data.chunk.content.length;
|
2086
2084
|
}
|
2087
2085
|
yield event;
|
2088
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
2089
2086
|
if (event.event === "on_chain_end" && event.data?.output) {
|
2090
2087
|
const output = event.data.output;
|
2091
2088
|
if (Array.isArray(output) && output.length > 0 && output[0]?.text) {
|
2092
2089
|
finalResponse = output[0].text;
|
2090
|
+
} else if (typeof output === "string") {
|
2091
|
+
finalResponse = output;
|
2092
|
+
} else if (output && typeof output === "object" && "output" in output) {
|
2093
|
+
finalResponse = output.output;
|
2093
2094
|
}
|
2094
2095
|
}
|
2095
2096
|
}
|
2096
|
-
if (
|
2097
|
+
if (outputSchema && finalResponse) {
|
2098
|
+
logger.info("\u{1F527} Attempting structured output conversion...");
|
2099
|
+
try {
|
2100
|
+
let conversionCompleted = false;
|
2101
|
+
let conversionResult = null;
|
2102
|
+
let conversionError = null;
|
2103
|
+
const _conversionPromise = this._attemptStructuredOutput(
|
2104
|
+
finalResponse,
|
2105
|
+
this.llm,
|
2106
|
+
outputSchema
|
2107
|
+
).then((result) => {
|
2108
|
+
conversionCompleted = true;
|
2109
|
+
conversionResult = result;
|
2110
|
+
return result;
|
2111
|
+
}).catch((error) => {
|
2112
|
+
conversionCompleted = true;
|
2113
|
+
conversionError = error;
|
2114
|
+
throw error;
|
2115
|
+
});
|
2116
|
+
let progressCount = 0;
|
2117
|
+
while (!conversionCompleted) {
|
2118
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
2119
|
+
if (!conversionCompleted) {
|
2120
|
+
progressCount++;
|
2121
|
+
yield {
|
2122
|
+
event: "on_structured_output_progress",
|
2123
|
+
data: {
|
2124
|
+
message: `Converting to structured output... (${progressCount * 2}s)`,
|
2125
|
+
elapsed: progressCount * 2
|
2126
|
+
}
|
2127
|
+
};
|
2128
|
+
}
|
2129
|
+
}
|
2130
|
+
if (conversionError) {
|
2131
|
+
throw conversionError;
|
2132
|
+
}
|
2133
|
+
if (conversionResult) {
|
2134
|
+
yield {
|
2135
|
+
event: "on_structured_output",
|
2136
|
+
data: { output: conversionResult }
|
2137
|
+
};
|
2138
|
+
if (this.memoryEnabled) {
|
2139
|
+
this.addToHistory(new AIMessage(`Structured result: ${JSON.stringify(conversionResult)}`));
|
2140
|
+
}
|
2141
|
+
logger.info("\u2705 Structured output successful");
|
2142
|
+
}
|
2143
|
+
} catch (e) {
|
2144
|
+
logger.warn(`\u26A0\uFE0F Structured output failed: ${e}`);
|
2145
|
+
yield {
|
2146
|
+
event: "on_structured_output_error",
|
2147
|
+
data: { error: e instanceof Error ? e.message : String(e) }
|
2148
|
+
};
|
2149
|
+
}
|
2150
|
+
} else if (this.memoryEnabled && finalResponse) {
|
2097
2151
|
this.addToHistory(new AIMessage(finalResponse));
|
2098
2152
|
}
|
2099
2153
|
logger.info(`\u{1F389} StreamEvents complete - ${eventCount} events emitted`);
|
@@ -2144,10 +2198,21 @@ var MCPAgent = class {
|
|
2144
2198
|
/**
|
2145
2199
|
* Attempt to create structured output from raw result with validation and retry logic.
|
2146
2200
|
*/
|
2147
|
-
async _attemptStructuredOutput(rawResult,
|
2201
|
+
async _attemptStructuredOutput(rawResult, llm, outputSchema) {
|
2148
2202
|
logger.info(`\u{1F504} Attempting structured output with schema: ${outputSchema}`);
|
2149
|
-
logger.info(`\u{1F504} Schema description: ${schemaDescription}`);
|
2150
2203
|
logger.info(`\u{1F504} Raw result: ${JSON.stringify(rawResult, null, 2)}`);
|
2204
|
+
let structuredLlm = null;
|
2205
|
+
let schemaDescription = "";
|
2206
|
+
logger.debug(`\u{1F504} Structured output requested, schema: ${JSON.stringify(zodToJsonSchema2(outputSchema), null, 2)}`);
|
2207
|
+
if (llm && "withStructuredOutput" in llm && typeof llm.withStructuredOutput === "function") {
|
2208
|
+
structuredLlm = llm.withStructuredOutput(outputSchema);
|
2209
|
+
} else if (llm) {
|
2210
|
+
structuredLlm = llm;
|
2211
|
+
} else {
|
2212
|
+
throw new Error("LLM is required for structured output");
|
2213
|
+
}
|
2214
|
+
schemaDescription = JSON.stringify(zodToJsonSchema2(outputSchema), null, 2);
|
2215
|
+
logger.info(`\u{1F504} Schema description: ${schemaDescription}`);
|
2151
2216
|
let textContent = "";
|
2152
2217
|
if (typeof rawResult === "string") {
|
2153
2218
|
textContent = rawResult;
|
@@ -2191,6 +2256,7 @@ var MCPAgent = class {
|
|
2191
2256
|
let chunkCount = 0;
|
2192
2257
|
for await (const chunk of stream) {
|
2193
2258
|
chunkCount++;
|
2259
|
+
logger.info(`Chunk ${chunkCount}: ${JSON.stringify(chunk, null, 2)}`);
|
2194
2260
|
if (typeof chunk === "string") {
|
2195
2261
|
try {
|
2196
2262
|
structuredResult = JSON.parse(chunk);
|
@@ -2206,7 +2272,6 @@ var MCPAgent = class {
|
|
2206
2272
|
logger.warn(`\u{1F504} Failed to parse chunk as JSON: ${chunk}`);
|
2207
2273
|
}
|
2208
2274
|
}
|
2209
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
2210
2275
|
if (chunkCount % 10 === 0) {
|
2211
2276
|
logger.info(`\u{1F504} Structured output streaming: ${chunkCount} chunks`);
|
2212
2277
|
}
|
@@ -3878,7 +3943,6 @@ export {
|
|
3878
3943
|
Telemetry,
|
3879
3944
|
ToolMessage2 as ToolMessage,
|
3880
3945
|
WebSocketConnector,
|
3881
|
-
createMCPServer,
|
3882
3946
|
createOAuthMCPConfig,
|
3883
3947
|
createReadableStreamFromGenerator,
|
3884
3948
|
loadConfigFile,
|
@@ -129,7 +129,7 @@ export declare class MCPAgent {
|
|
129
129
|
* Yields LangChain StreamEvent objects from the underlying streamEvents() method.
|
130
130
|
* This provides token-level streaming and fine-grained event updates.
|
131
131
|
*/
|
132
|
-
streamEvents(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[]): AsyncGenerator<StreamEvent, void, void>;
|
132
|
+
streamEvents<T = string>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>): AsyncGenerator<StreamEvent, void, void>;
|
133
133
|
/**
|
134
134
|
* Attempt to create structured output from raw result with validation and retry logic.
|
135
135
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mcp_agent.d.ts","sourceRoot":"","sources":["../../../src/agents/mcp_agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AAEzE,OAAO,KAAK,EAAE,0BAA0B,EAAqB,MAAM,sCAAsC,CAAA;AAEzG,OAAO,KAAK,EACV,WAAW,EACZ,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,uBAAuB,EAAiB,MAAM,uBAAuB,CAAA;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AACrE,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,OAAO,EAGL,aAAa,EAEd,MAAM,0BAA0B,CAAA;AAQjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAO7D,qBAAa,QAAQ;IACnB,OAAO,CAAC,GAAG,CAAC,CAA4B;IACxC,OAAO,CAAC,MAAM,CAAC,CAAW;IAC1B,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,eAAe,CAAU;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,eAAe,UAAO,EACtB,eAAe,CAAC,EAAE,WAAW,EAAE,EAC/B,YAAY,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,GAC1B,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC;IAsO1C;;OAEG;YACW,wBAAwB;IAgJtC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAgCjC;;OAEG;IACH,OAAO,CAAC,uBAAuB;CAuBhC"}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
/**
|
2
|
+
* MCP-UI Adapter Utilities
|
3
|
+
*
|
4
|
+
* Pure functions to convert mcp-use high-level UIResource definitions
|
5
|
+
* into @mcp-ui/server compatible resource objects.
|
6
|
+
*
|
7
|
+
* Ref: https://mcpui.dev/guide/server/typescript/usage-examples
|
8
|
+
*/
|
9
|
+
import type { UIResourceContent, UIResourceDefinition, UIEncoding } from '../types/resource.js';
|
10
|
+
/**
|
11
|
+
* Configuration for building widget URLs
|
12
|
+
*/
|
13
|
+
export interface UrlConfig {
|
14
|
+
baseUrl: string;
|
15
|
+
port: number | string;
|
16
|
+
}
|
17
|
+
/**
|
18
|
+
* Build the full URL for a widget including query parameters
|
19
|
+
*
|
20
|
+
* @param widget - Widget identifier
|
21
|
+
* @param props - Parameters to pass as query params
|
22
|
+
* @param config - URL configuration (baseUrl and port)
|
23
|
+
* @returns Complete widget URL with encoded parameters
|
24
|
+
*/
|
25
|
+
export declare function buildWidgetUrl(widget: string, props: Record<string, any> | undefined, config: UrlConfig): string;
|
26
|
+
/**
|
27
|
+
* Create a UIResource for an external URL (iframe)
|
28
|
+
*
|
29
|
+
* @param uri - Resource URI (must start with ui://)
|
30
|
+
* @param iframeUrl - URL to load in iframe
|
31
|
+
* @param encoding - Encoding type ('text' or 'blob')
|
32
|
+
* @returns UIResourceContent object
|
33
|
+
*/
|
34
|
+
export declare function createExternalUrlResource(uri: string, iframeUrl: string, encoding?: UIEncoding): UIResourceContent;
|
35
|
+
/**
|
36
|
+
* Create a UIResource for raw HTML content
|
37
|
+
*
|
38
|
+
* @param uri - Resource URI (must start with ui://)
|
39
|
+
* @param htmlString - HTML content to render
|
40
|
+
* @param encoding - Encoding type ('text' or 'blob')
|
41
|
+
* @returns UIResourceContent object
|
42
|
+
*/
|
43
|
+
export declare function createRawHtmlResource(uri: string, htmlString: string, encoding?: UIEncoding): UIResourceContent;
|
44
|
+
/**
|
45
|
+
* Create a UIResource for Remote DOM scripting
|
46
|
+
*
|
47
|
+
* @param uri - Resource URI (must start with ui://)
|
48
|
+
* @param script - JavaScript code for remote DOM manipulation
|
49
|
+
* @param framework - Framework for remote DOM ('react' or 'webcomponents')
|
50
|
+
* @param encoding - Encoding type ('text' or 'blob')
|
51
|
+
* @returns UIResourceContent object
|
52
|
+
*/
|
53
|
+
export declare function createRemoteDomResource(uri: string, script: string, framework?: 'react' | 'webcomponents', encoding?: UIEncoding): UIResourceContent;
|
54
|
+
/**
|
55
|
+
* Create a UIResource from a high-level definition
|
56
|
+
*
|
57
|
+
* This is the main function that routes to the appropriate resource creator
|
58
|
+
* based on the discriminated union type.
|
59
|
+
*
|
60
|
+
* @param definition - UIResource definition (discriminated union)
|
61
|
+
* @param params - Runtime parameters for the widget (for externalUrl type)
|
62
|
+
* @param config - URL configuration for building widget URLs
|
63
|
+
* @returns UIResourceContent object
|
64
|
+
*/
|
65
|
+
export declare function createUIResourceFromDefinition(definition: UIResourceDefinition, params: Record<string, any>, config: UrlConfig): UIResourceContent;
|
66
|
+
//# sourceMappingURL=mcp-ui-adapter.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"mcp-ui-adapter.d.ts","sourceRoot":"","sources":["../../../../src/server/adapters/mcp-ui-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACX,MAAM,sBAAsB,CAAA;AAE7B;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,EACtC,MAAM,EAAE,SAAS,GAChB,MAAM,CAkBR;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,UAAmB,GAC5B,iBAAiB,CAMnB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,UAAmB,GAC5B,iBAAiB,CAMnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,OAAO,GAAG,eAAyB,EAC9C,QAAQ,GAAE,UAAmB,GAC5B,iBAAiB,CAMnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,SAAS,GAChB,iBAAiB,CAyBnB"}
|