Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
36 changes: 1 addition & 35 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
} from '@modelcontextprotocol/ext-apps/server';
import { z } from 'zod';
import { parseToolConfigFromArgs, filterTools } from './config/toolConfig.js';
import {
getCoreTools,
getElicitationTools,
getResourceFallbackTools
} from './tools/toolRegistry.js';
import { getCoreTools, getElicitationTools } from './tools/toolRegistry.js';
import { getAllResources } from './resources/resourceRegistry.js';
import { getAllPrompts } from './prompts/promptRegistry.js';
import { getVersionInfo } from './utils/versionUtils.js';
Expand Down Expand Up @@ -65,11 +61,9 @@
// Split into categories for capability-aware registration
const coreTools = getCoreTools();
const elicitationTools = getElicitationTools();
const resourceFallbackTools = getResourceFallbackTools();

const enabledCoreTools = filterTools(coreTools, config);
const enabledElicitationTools = filterTools(elicitationTools, config);
const enabledResourceFallbackTools = filterTools(resourceFallbackTools, config);

// Create an MCP server
const server = new McpServer(
Expand Down Expand Up @@ -106,7 +100,7 @@
// This tells clients (like Claude Desktop) that this is an MCP App
uiResources.forEach((resource) => {
registerAppResource(
server as any,

Check warning on line 103 in src/index.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
resource.name,
resource.uri,
{ mimeType: RESOURCE_MIME_TYPE, description: resource.description },
Expand Down Expand Up @@ -279,34 +273,6 @@
});
}

// Register resource fallback tools for clients that don't support resources
// Note: Resources are a core MCP feature supported by most clients.
// However, some clients (like smolagents) don't support resources at all.
// These fallback tools provide the same content as resources but via tool calls instead.
//
// Configuration via CLIENT_NEEDS_RESOURCE_FALLBACK environment variable:
// - unset (default) = Skip fallback tools (assume client supports resources)
// - "true" = Provide fallback tools (client does NOT support resources)
const clientNeedsResourceFallback =
process.env.CLIENT_NEEDS_RESOURCE_FALLBACK?.toLowerCase() === 'true';

if (clientNeedsResourceFallback && enabledResourceFallbackTools.length > 0) {
server.server.sendLoggingMessage({
level: 'info',
data: `CLIENT_NEEDS_RESOURCE_FALLBACK=true. Registering ${enabledResourceFallbackTools.length} resource fallback tools`
});

enabledResourceFallbackTools.forEach((tool) => {
tool.installTo(server);
});
toolsAdded = true;
} else if (enabledResourceFallbackTools.length > 0) {
server.server.sendLoggingMessage({
level: 'debug',
data: `CLIENT_NEEDS_RESOURCE_FALLBACK not set or false. Skipping ${enabledResourceFallbackTools.length} resource fallback tools (client supports resources)`
});
}

// Notify client about tool list changes if any tools were added
if (toolsAdded) {
try {
Expand Down
20 changes: 2 additions & 18 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,16 @@
* ```typescript
* import { mapboxStyleLayers } from '@mapbox/mcp-devkit-server/resources';
*
* // Use directly - httpRequest already configured
* // Use directly - already configured
* const result = await mapboxStyleLayers.read();
* ```
*
* @example Advanced usage with custom pipeline
* ```typescript
* import { MapboxDocumentationResource } from '@mapbox/mcp-devkit-server/resources';
* import { httpRequest } from '@mapbox/mcp-devkit-server/utils';
*
* const customResource = new MapboxDocumentationResource({ httpRequest });
* ```
*/

import { httpRequest } from '../utils/httpPipeline.js';

// Export all resource classes
export { MapboxStyleLayersResource } from './mapbox-style-layers-resource/MapboxStyleLayersResource.js';
export { MapboxStreetsV8FieldsResource } from './mapbox-streets-v8-fields-resource/MapboxStreetsV8FieldsResource.js';
export { MapboxTokenScopesResource } from './mapbox-token-scopes-resource/MapboxTokenScopesResource.js';
export { MapboxLayerTypeMappingResource } from './mapbox-layer-type-mapping-resource/MapboxLayerTypeMappingResource.js';
export { MapboxDocumentationResource } from './mapbox-documentation-resource/MapboxDocumentationResource.js';
export { PreviewStyleUIResource } from './ui-apps/PreviewStyleUIResource.js';
export { StyleComparisonUIResource } from './ui-apps/StyleComparisonUIResource.js';
export { GeojsonPreviewUIResource } from './ui-apps/GeojsonPreviewUIResource.js';
Expand All @@ -43,12 +32,12 @@ import { MapboxStyleLayersResource } from './mapbox-style-layers-resource/Mapbox
import { MapboxStreetsV8FieldsResource } from './mapbox-streets-v8-fields-resource/MapboxStreetsV8FieldsResource.js';
import { MapboxTokenScopesResource } from './mapbox-token-scopes-resource/MapboxTokenScopesResource.js';
import { MapboxLayerTypeMappingResource } from './mapbox-layer-type-mapping-resource/MapboxLayerTypeMappingResource.js';
import { MapboxDocumentationResource } from './mapbox-documentation-resource/MapboxDocumentationResource.js';
import { PreviewStyleUIResource } from './ui-apps/PreviewStyleUIResource.js';
import { StyleComparisonUIResource } from './ui-apps/StyleComparisonUIResource.js';
import { GeojsonPreviewUIResource } from './ui-apps/GeojsonPreviewUIResource.js';

// Export pre-configured resource instances with short, clean names

/** Mapbox style layers reference */
export const mapboxStyleLayers = new MapboxStyleLayersResource();

Expand All @@ -61,11 +50,6 @@ export const mapboxTokenScopes = new MapboxTokenScopesResource();
/** Mapbox layer type mapping reference */
export const mapboxLayerTypeMapping = new MapboxLayerTypeMappingResource();

/** Mapbox documentation */
export const mapboxDocumentation = new MapboxDocumentationResource({
httpRequest
});

/** Preview style UI resource */
export const previewStyleUI = new PreviewStyleUIResource();

Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions src/resources/resourceRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@ import { MapboxStyleLayersResource } from './mapbox-style-layers-resource/Mapbox
import { MapboxStreetsV8FieldsResource } from './mapbox-streets-v8-fields-resource/MapboxStreetsV8FieldsResource.js';
import { MapboxTokenScopesResource } from './mapbox-token-scopes-resource/MapboxTokenScopesResource.js';
import { MapboxLayerTypeMappingResource } from './mapbox-layer-type-mapping-resource/MapboxLayerTypeMappingResource.js';
import { MapboxDocumentationResource } from './mapbox-documentation-resource/MapboxDocumentationResource.js';
import { PreviewStyleUIResource } from './ui-apps/PreviewStyleUIResource.js';
import { StyleComparisonUIResource } from './ui-apps/StyleComparisonUIResource.js';
import { GeojsonPreviewUIResource } from './ui-apps/GeojsonPreviewUIResource.js';
import { httpRequest } from '../utils/httpPipeline.js';

// Central registry of all resources
export const ALL_RESOURCES = [
new MapboxStyleLayersResource(),
new MapboxStreetsV8FieldsResource(),
new MapboxTokenScopesResource(),
new MapboxLayerTypeMappingResource(),
new MapboxDocumentationResource({ httpRequest }),
// MCP Apps UI resources (ui:// scheme)
new PreviewStyleUIResource(),
new StyleComparisonUIResource(),
Expand Down

This file was deleted.

85 changes: 0 additions & 85 deletions src/tools/get-mapbox-doc-source-tool/GetMapboxDocSourceTool.ts

This file was deleted.

23 changes: 0 additions & 23 deletions src/tools/get-reference-tool/GetReferenceTool.input.schema.ts

This file was deleted.

Loading
Loading