-
Notifications
You must be signed in to change notification settings - Fork 1k
Add icon and website url metadata #587
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: tonxipad <[email protected]>
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: tonxipad <[email protected]>
|
@claude review the pr |
|
Claude finished @tonxxd's task —— View job Code Review Complete ✅PR #587: Add icon and website url metadata I've reviewed the implementation of SEP-973 support for icons and website URLs. Overall, the implementation is solid and well-structured. Here's my detailed feedback: ✅ Strengths
🔍 Issues & Recommendations1. Type Safety Concerns (High Priority)Location: The use of // Current approach
this.server = new OfficialMcpServer({
name: config.name,
version: config.version,
icons: config.icons,
websiteUrl: config.websiteUrl,
} as any);Recommendation:
interface TemporaryServerConfig extends ServerCapabilities {
icons?: Icon[];
websiteUrl?: string;
}
this.server = new OfficialMcpServer({
name: config.name,
version: config.version,
icons: config.icons,
websiteUrl: config.websiteUrl,
} as TemporaryServerConfig);
2. Security: Missing URL Validation (High Priority)Locations:
The documentation warns that consumers "MUST take steps to ensure URLs are from the same domain or a trusted domain," but there's no validation implemented. This could lead to:
Recommendations:
export function validateIconUrl(url: string, trustedDomains?: string[]): boolean {
// Validate URL format, check against trusted domains
// Reject javascript: and data: URIs with scripts
}
// For external URLs, validate domain
// For data URIs, validate MIME type is image/*
// Consider adding sandbox attributes for SVG rendering
3. IconRenderer Performance Issue (Medium Priority)Location: The comment says "For now, just use the first icon" but the // Current: always uses first icon
const icon = icons[0];Recommendation: Implement size-based selection: function selectBestIcon(icons: Icon[], targetSize: number): Icon {
// Parse sizes field (e.g., "48x48", "any")
// Select closest match to targetSize
// Fall back to first icon if no sizes specified
return bestMatch || icons[0];
}This would provide better visual quality and potentially reduce bandwidth for retina displays. 4. Type Casting Inconsistency (Low Priority)Locations:
These cast to Recommendation: Create a shared helper or type guard: // In shared/utils.ts
export function getEntityIcons(entity: any): Icon[] | undefined {
return entity.icons;
}This centralizes the type assertion and makes it easier to remove once SDK types are updated. 5. Missing Error Handling in IconRenderer (Medium Priority)Location: The component tracks error state but only shows fallback. If an icon fails to load, there's no logging or debugging info. Recommendation: Add optional error logging: onError={(e) => {
if (process.env.NODE_ENV === 'development') {
console.warn('Failed to load icon:', icon.src, e);
}
setError(true);
}}6. Documentation: No Migration Guide (Low Priority)The PR description shows "before/after" examples, but there's no migration guide for users who want to add icons to existing servers. Recommendation: Consider adding a brief migration guide in CHANGELOG or documentation about:
🧪 Testing SuggestionsThe PR mentions no new unit tests were added. While the schema changes are straightforward, consider adding:
📋 Minor Observations
🎯 SummaryOverall Assessment: This is a solid implementation of SEP-973 with good structure and backwards compatibility. The main concerns are:
Recommendation: ✅ Approve with suggested improvements The implementation is functional and safe to merge, but I strongly recommend addressing the security concerns (URL validation) before deploying to production. The type safety issues can be addressed when the SDK is updated. 📝 Action ItemsIf you'd like me to implement any of these suggestions, let me know! I can:
Todo List
|
Co-authored-by: tonxipad <[email protected]>
Co-authored-by: tonxipad <[email protected]>
Co-authored-by: tonxipad <[email protected]>
|
needs to wait for the official sdk support |
|
@tonxxd Would it be okay if I jump in and review this PR? I noticed a few areas where I can help with improvements. |
|
@aryasoni98 the feature is not yet in the official sdk so for now it does not make sense to go forward, will reopen it once released |
Pull Request Description
Changes
This PR implements SEP-973 by adding
iconsandwebsiteUrlas optional metadata fields to various MCP entities. This allows clients to display visual cues and links to documentation for implementations, tools, resources, and prompts.Specifically, this PR:
Iconinterface.iconsfield toToolDefinition,ResourceDefinition,ResourceTemplateDefinition, andPromptDefinition.iconsandwebsiteUrlfields toServerConfig(representingImplementationmetadata).McpServerconstructor and registration methods (tool,resource,resourceTemplate,prompt) to accept and pass these new metadata fields.Implementation Details
IconInterface: Defined inlibraries/typescript/packages/mcp-use/src/server/types/common.tswithsrc,mimeType?, andsizes?properties.ServerConfig(forImplementationmetadata) insrc/server/types/common.tsnow includesicons?: Icon[]andwebsiteUrl?: string.ToolDefinitioninsrc/server/types/tool.tsnow includesicons?: Icon[].ResourceDefinitionandResourceTemplateDefinitioninsrc/server/types/resource.tsnow includeicons?: Icon[].PromptDefinitioninsrc/server/types/prompt.tsnow includesicons?: Icon[].McpServerclass insrc/server/mcp-server.tshas been updated to:config.iconsandconfig.websiteUrlto theOfficialMcpServerconstructor.toolDefinition.iconstothis.server.registerTool.resourceDefinition.iconstothis.server.registerResource.resourceTemplateDefinition.iconswithin the metadata tothis.server.registerResource.promptDefinition.iconstothis.server.registerPrompt.as any) were used inmcp-server.tsto temporarily bypass type mismatches with@modelcontextprotocol/sdkas its types have not yet been updated to reflect SEP-973. These assertions can be removed once the SDK is updated.Icontype is now exported fromlibraries/typescript/packages/mcp-use/src/server/types/index.tsandlibraries/typescript/packages/mcp-use/src/server/index.ts.Example Usage (Before)
Example Usage (After)
Documentation Updates
No separate documentation files were updated in this PR. The changes align with the SEP-973 specification.
Testing
npm installnpm run buildnpm run typecheckAll commands executed successfully, confirming that the codebase compiles without TypeScript errors after the changes.
iconsandwebsiteUrlare optional, which is reflected in the implementation. TheIconinterface supports both URL and base64 data URIs, and flexiblesizesstrings.Backwards Compatibility
These changes are fully backwards compatible. Both
iconsandwebsiteUrlare optional fields. Existing clients and servers that do not provide or consume these fields will continue to function as before, falling back to existing behavior.Related Issues
Closes #MCP-814
Linear Issue: MCP-814