Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions patches/@modelcontextprotocol+sdk+1.25.1.patch
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,20 @@ index e10bb3d..2e99bee 100644
}
/**
diff --git a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js b/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
index 23639ce..7b8a325 100644
index 23639ce..75f18b5 100644
--- a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
+++ b/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
@@ -194,15 +194,20 @@ export class McpServer {
@@ -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) {
Expand Down Expand Up @@ -64,3 +74,49 @@ index 23639ce..7b8a325 100644
}
}
/**
@@ -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]) {
25 changes: 14 additions & 11 deletions src/tools/BaseTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import type {
} from '@modelcontextprotocol/sdk/server/mcp.js';
import type {
ToolAnnotations,
CallToolResult
CallToolResult,
Icon
} from '@modelcontextprotocol/sdk/types.js';
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
import type { ZodTypeAny } from 'zod';
Expand All @@ -23,14 +24,17 @@ export abstract class BaseTool<

readonly inputSchema: InputSchema;
readonly outputSchema?: OutputSchema;
readonly icons?: Icon[];
protected server: McpServer | null = null;

constructor(params: {
inputSchema: InputSchema;
outputSchema?: OutputSchema;
icons?: Icon[];
}) {
this.inputSchema = params.inputSchema;
this.outputSchema = params.outputSchema;
this.icons = params.icons;
}

/**
Expand All @@ -39,15 +43,7 @@ export abstract class BaseTool<
installTo(server: McpServer): RegisteredTool {
this.server = server;

const config: {
title?: string;
description?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
inputSchema?: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
outputSchema?: any;
annotations?: ToolAnnotations;
} = {
const config = {
title: this.annotations.title,
description: this.description,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -57,11 +53,18 @@ export abstract class BaseTool<

// Add outputSchema if provided
if (this.outputSchema) {
config.outputSchema =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(config as any).outputSchema =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(this.outputSchema as unknown as z.ZodObject<any>).shape;
}

// Add icons if provided (not yet in SDK type definition)
if (this.icons) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(config as any).icons = this.icons;
}

return server.registerTool(
this.name,
config,
Expand Down
19 changes: 17 additions & 2 deletions src/tools/MapboxApiBasedTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@ import type { ZodTypeAny } from 'zod';
import { BaseTool } from './BaseTool.js';
import type {
CallToolResult,
ToolAnnotations
ToolAnnotations,
Icon
} from '@modelcontextprotocol/sdk/types.js';
import type { HttpRequest } from '../utils/types.js';
import { context, trace, SpanStatusCode } from '@opentelemetry/api';
import type { ToolExecutionContext } from '../utils/tracing.js';
import { createToolExecutionContext } from '../utils/tracing.js';

/**
* Default Mapbox icon for all Mapbox tools
*/
const MAPBOX_ICON: Icon[] = [
{
src: 'https://avatars.githubusercontent.com/u/600935?s=200&v=4',
mimeType: 'image/png',
sizes: ['200x200']
}
];

export abstract class MapboxApiBasedTool<
InputSchema extends ZodTypeAny,
OutputSchema extends ZodTypeAny = ZodTypeAny
Expand All @@ -36,7 +48,10 @@ export abstract class MapboxApiBasedTool<
outputSchema?: OutputSchema;
httpRequest: HttpRequest;
}) {
super(params);
super({
...params,
icons: MAPBOX_ICON
});
this.httpRequest = params.httpRequest;
}

Expand Down
16 changes: 14 additions & 2 deletions src/tools/resource-reader-tool/ResourceReaderTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@
// Licensed under the MIT License.

import { BaseTool } from '../BaseTool.js';
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
import type { CallToolResult, Icon } from '@modelcontextprotocol/sdk/types.js';
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
import type { ResourceReaderToolInput } from './ResourceReaderTool.input.schema.js';
import { ResourceReaderToolInputSchema } from './ResourceReaderTool.input.schema.js';
import { ResourceReaderToolOutputSchema } from './ResourceReaderTool.output.schema.js';
import { getResourceByUri } from '../../resources/resourceRegistry.js';

/**
* Default Mapbox icon
*/
const MAPBOX_ICON: Icon[] = [
{
src: 'https://avatars.githubusercontent.com/u/600935?s=200&v=4',
mimeType: 'image/png',
sizes: ['200x200']
}
];

/**
* Tool for reading MCP resources via the tool interface.
* This provides a fallback mechanism for clients that don't support the MCP resource API.
Expand All @@ -31,7 +42,8 @@ export class ResourceReaderTool extends BaseTool<
constructor() {
super({
inputSchema: ResourceReaderToolInputSchema,
outputSchema: ResourceReaderToolOutputSchema
outputSchema: ResourceReaderToolOutputSchema,
icons: MAPBOX_ICON
});
}

Expand Down
20 changes: 16 additions & 4 deletions src/tools/version-tool/VersionTool.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import { context, SpanStatusCode, trace } from '@opentelemetry/api';
import { createLocalToolExecutionContext } from '../../utils/tracing.js';
// Copyright (c) Mapbox, Inc.
// Licensed under the MIT License.

import { context, SpanStatusCode, trace } from '@opentelemetry/api';
import { createLocalToolExecutionContext } from '../../utils/tracing.js';
import { BaseTool } from '../BaseTool.js';
import { getVersionInfo } from '../../utils/versionUtils.js';
import { VersionSchema } from './VersionTool.input.schema.js';
import { VersionResponseSchema } from './VersionTool.output.schema.js';
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
import type { CallToolResult, Icon } from '@modelcontextprotocol/sdk/types.js';

/**
* Default Mapbox icon
*/
const MAPBOX_ICON: Icon[] = [
{
src: 'https://avatars.githubusercontent.com/u/600935?s=200&v=4',
mimeType: 'image/png',
sizes: ['200x200']
}
];

export class VersionTool extends BaseTool<
typeof VersionSchema,
Expand All @@ -27,7 +38,8 @@ export class VersionTool extends BaseTool<
constructor() {
super({
inputSchema: VersionSchema,
outputSchema: VersionResponseSchema
outputSchema: VersionResponseSchema,
icons: MAPBOX_ICON
});
}

Expand Down