Skip to content

Commit 185e067

Browse files
Clarify resource fallback logic: for clients without resource support (like smolagents)
Update comments and logic to reflect the real use case: resource fallback tools are for clients that don't support resources at all (like smolagents), not for buggy resource implementations. Changes: - Add 'claude' to allowlist (Claude Desktop now supports resources properly) - Update comments to clarify this is for clients without resource support - Change from "may not support properly" to "don't support resources" - Document smolagents as the primary use case Known clients WITH resource support (skip fallback tools): - inspector - vscode - claude (Claude Desktop/Code) Clients WITHOUT resource support (get fallback tools): - smolagents - unknown/new clients (safer default) All tests passing (536 tests).
1 parent 5e89269 commit 185e067

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

src/index.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,21 +253,24 @@ async function main() {
253253
});
254254
}
255255

256-
// Register resource fallback tools for clients that may not support resources properly
257-
// Note: Resources are a core MCP feature, but not all clients support them perfectly.
256+
// Register resource fallback tools for clients that don't support resources
257+
// Note: Resources are a core MCP feature, but some clients (like smolagents) don't support them.
258+
// These fallback tools provide the same content as resources but via tool calls instead.
258259
// We use an allowlist approach: only skip fallback tools for clients we KNOW support resources.
259260
// This is safer than blocklisting - unknown clients get fallback tools by default.
260261
const clientVersion = server.server.getClientVersion();
261262
const clientName = clientVersion?.name?.toLowerCase() || '';
262263

263-
// Known clients with proper resource support (can skip fallback tools)
264-
const supportsResourcesProperly =
265-
clientName.includes('inspector') || clientName.includes('vscode');
264+
// Known clients with resource support (can skip fallback tools)
265+
const supportsResources =
266+
clientName.includes('inspector') ||
267+
clientName.includes('vscode') ||
268+
clientName.includes('claude');
266269

267-
if (!supportsResourcesProperly && enabledResourceFallbackTools.length > 0) {
270+
if (!supportsResources && enabledResourceFallbackTools.length > 0) {
268271
server.server.sendLoggingMessage({
269272
level: 'info',
270-
data: `Client "${clientVersion?.name}" may need resource fallback tools. Registering ${enabledResourceFallbackTools.length} resource fallback tools`
273+
data: `Client "${clientVersion?.name}" does not support resources. Registering ${enabledResourceFallbackTools.length} resource fallback tools`
271274
});
272275

273276
enabledResourceFallbackTools.forEach((tool) => {
@@ -277,7 +280,7 @@ async function main() {
277280
} else if (enabledResourceFallbackTools.length > 0) {
278281
server.server.sendLoggingMessage({
279282
level: 'debug',
280-
data: `Client "${clientVersion?.name}" supports resources properly. Skipping ${enabledResourceFallbackTools.length} resource fallback tools`
283+
data: `Client "${clientVersion?.name}" supports resources. Skipping ${enabledResourceFallbackTools.length} resource fallback tools`
281284
});
282285
}
283286

src/tools/toolRegistry.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ export const CORE_TOOLS = [
6969
export const ELICITATION_TOOLS = [] as const;
7070

7171
/**
72-
* Tools that serve as bridges/workarounds for missing resource support
73-
* These tools are only registered if client does NOT support resources properly
72+
* Tools that serve as bridges for clients without resource support
73+
* These tools are only registered if client does NOT support resources
7474
*
75-
* Context: These tools exist as workarounds for clients (like Claude Desktop) that
76-
* can list resources but don't automatically fetch them. Clients that properly
77-
* support resources don't need these bridge tools.
75+
* Context: Some MCP clients (like smolagents) don't support resources at all.
76+
* These tools provide the same content as resources but via tool calls instead,
77+
* allowing these clients to access reference data and documentation.
78+
* Clients that support resources (Claude Desktop, VS Code, Inspector) don't need these.
7879
*
7980
* - GetReferenceTool: Provides access to reference resources (style layers, Streets v8 fields, token scopes, layer type mapping)
8081
* - GetMapboxDocSourceTool: Provides access to Mapbox documentation (resource://mapbox-documentation)

0 commit comments

Comments
 (0)