-
Notifications
You must be signed in to change notification settings - Fork 29
[FUTURE] Task-based optimization tool for async execution #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| diff --git a/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js b/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js | ||
| index e10bb3d..2e99bee 100644 | ||
| --- a/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js | ||
| +++ b/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js | ||
| @@ -197,15 +197,20 @@ class McpServer { | ||
| return; | ||
| } | ||
| if (!result.structuredContent) { | ||
| - throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`); | ||
| + // Log warning but don't throw - allow tools to omit structured content | ||
| + console.warn(`[MCP SDK Patch] Output validation warning: Tool ${toolName} has an output schema but no structured content was provided`); | ||
| } | ||
| - // if the tool has an output schema, validate structured content | ||
| - const outputObj = (0, zod_compat_js_1.normalizeObjectSchema)(tool.outputSchema); | ||
| - const parseResult = await (0, zod_compat_js_1.safeParseAsync)(outputObj, result.structuredContent); | ||
| - if (!parseResult.success) { | ||
| - const error = 'error' in parseResult ? parseResult.error : 'Unknown error'; | ||
| - const errorMessage = (0, zod_compat_js_1.getParseErrorMessage)(error); | ||
| - throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${errorMessage}`); | ||
| + else { | ||
| + // if the tool has an output schema, validate structured content | ||
| + const outputObj = (0, zod_compat_js_1.normalizeObjectSchema)(tool.outputSchema); | ||
| + const parseResult = await (0, zod_compat_js_1.safeParseAsync)(outputObj, result.structuredContent); | ||
| + if (!parseResult.success) { | ||
| + const error = 'error' in parseResult ? parseResult.error : 'Unknown error'; | ||
| + const errorMessage = (0, zod_compat_js_1.getParseErrorMessage)(error); | ||
| + // Log warning but don't throw - allow schema mismatches | ||
| + console.warn(`[MCP SDK Patch] Output validation warning: Invalid structured content for tool ${toolName}: ${errorMessage}`); | ||
| + // Keep the structuredContent despite validation failure | ||
| + } | ||
| } | ||
| } | ||
| /** | ||
| diff --git a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js b/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js | ||
| index 23639ce..75f18b5 100644 | ||
| --- a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js | ||
| +++ b/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js | ||
| @@ -85,6 +85,9 @@ export class McpServer { | ||
| execution: tool.execution, | ||
| _meta: tool._meta | ||
| }; | ||
| + if (tool.icons) { | ||
| + toolDefinition.icons = tool.icons; | ||
| + } | ||
| if (tool.outputSchema) { | ||
| const obj = normalizeObjectSchema(tool.outputSchema); | ||
| if (obj) { | ||
| @@ -194,15 +197,20 @@ export class McpServer { | ||
| return; | ||
| } | ||
| if (!result.structuredContent) { | ||
| - throw new McpError(ErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`); | ||
| + // Log warning but don't throw - allow tools to omit structured content | ||
| + console.warn(`[MCP SDK Patch] Output validation warning: Tool ${toolName} has an output schema but no structured content was provided`); | ||
| } | ||
| - // if the tool has an output schema, validate structured content | ||
| - const outputObj = normalizeObjectSchema(tool.outputSchema); | ||
| - const parseResult = await safeParseAsync(outputObj, result.structuredContent); | ||
| - if (!parseResult.success) { | ||
| - const error = 'error' in parseResult ? parseResult.error : 'Unknown error'; | ||
| - const errorMessage = getParseErrorMessage(error); | ||
| - throw new McpError(ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${errorMessage}`); | ||
| + else { | ||
| + // if the tool has an output schema, validate structured content | ||
| + const outputObj = normalizeObjectSchema(tool.outputSchema); | ||
| + const parseResult = await safeParseAsync(outputObj, result.structuredContent); | ||
| + if (!parseResult.success) { | ||
| + const error = 'error' in parseResult ? parseResult.error : 'Unknown error'; | ||
| + const errorMessage = getParseErrorMessage(error); | ||
| + // Log warning but don't throw - allow schema mismatches | ||
| + console.warn(`[MCP SDK Patch] Output validation warning: Invalid structured content for tool ${toolName}: ${errorMessage}`); | ||
| + // Keep the structuredContent despite validation failure | ||
| + } | ||
| } | ||
| } | ||
| /** | ||
| @@ -602,7 +610,7 @@ export class McpServer { | ||
| } | ||
| return registeredPrompt; | ||
| } | ||
| - _createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, execution, _meta, handler) { | ||
| + _createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, execution, _meta, icons, handler) { | ||
| // Validate tool name according to SEP specification | ||
| validateAndWarnToolName(name); | ||
| const registeredTool = { | ||
| @@ -613,6 +621,7 @@ export class McpServer { | ||
| annotations, | ||
| execution, | ||
| _meta, | ||
| + icons, | ||
| handler: handler, | ||
| enabled: true, | ||
| disable: () => registeredTool.update({ enabled: false }), | ||
| @@ -641,6 +650,8 @@ export class McpServer { | ||
| registeredTool.annotations = updates.annotations; | ||
| if (typeof updates._meta !== 'undefined') | ||
| registeredTool._meta = updates._meta; | ||
| + if (typeof updates.icons !== 'undefined') | ||
| + registeredTool.icons = updates.icons; | ||
| if (typeof updates.enabled !== 'undefined') | ||
| registeredTool.enabled = updates.enabled; | ||
| this.sendToolListChanged(); | ||
| @@ -690,7 +701,7 @@ export class McpServer { | ||
| } | ||
| } | ||
| const callback = rest[0]; | ||
| - return this._createRegisteredTool(name, undefined, description, inputSchema, outputSchema, annotations, { taskSupport: 'forbidden' }, undefined, callback); | ||
| + return this._createRegisteredTool(name, undefined, description, inputSchema, outputSchema, annotations, { taskSupport: 'forbidden' }, undefined, undefined, callback); | ||
| } | ||
| /** | ||
| * Registers a tool with a config object and callback. | ||
| @@ -699,8 +710,8 @@ export class McpServer { | ||
| if (this._registeredTools[name]) { | ||
| throw new Error(`Tool ${name} is already registered`); | ||
| } | ||
| - const { title, description, inputSchema, outputSchema, annotations, _meta } = config; | ||
| - return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, { taskSupport: 'forbidden' }, _meta, cb); | ||
| + const { title, description, inputSchema, outputSchema, annotations, _meta, icons } = config; | ||
| + return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, { taskSupport: 'forbidden' }, _meta, icons, cb); | ||
| } | ||
| prompt(name, ...rest) { | ||
| if (this._registeredPrompts[name]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@modelcontextprotocol/sdk 1.25.1 / package.json
Total vulnerabilities: 1
-