Skip to content

Commit 5e89269

Browse files
Address code review: Invert resource fallback logic for safer client compatibility
Per @Valiunia's review feedback, invert the resource fallback tool logic to use an allowlist approach instead of blocklist. This is safer for unknown clients. Changes: - OLD: Only provide fallback tools if client name includes 'claude' (blocklist) - NEW: Provide fallback tools to ALL clients UNLESS we know they support resources (allowlist) Known clients with proper resource support (skip fallback tools): - inspector - vscode Benefits: - Unknown/new clients get fallback tools by default (safer) - No risk of missing clients that need resource fallback - More defensive approach for ecosystem compatibility Related: PR #61 review comments All tests passing (536 tests).
1 parent b29c23f commit 5e89269

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/index.ts

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

256-
// Register resource fallback tools for clients with known resource support issues
257-
// Note: Resources are a core MCP feature, but some clients (like Claude Desktop) can list
258-
// resources but don't automatically fetch them. We detect these clients by name.
259-
// Most modern MCP clients (Inspector, VS Code, etc.) support resources properly.
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.
258+
// We use an allowlist approach: only skip fallback tools for clients we KNOW support resources.
259+
// This is safer than blocklisting - unknown clients get fallback tools by default.
260260
const clientVersion = server.server.getClientVersion();
261261
const clientName = clientVersion?.name?.toLowerCase() || '';
262262

263-
// Known clients with resource support issues
264-
const needsResourceFallback = clientName.includes('claude');
263+
// Known clients with proper resource support (can skip fallback tools)
264+
const supportsResourcesProperly =
265+
clientName.includes('inspector') || clientName.includes('vscode');
265266

266-
if (needsResourceFallback && enabledResourceFallbackTools.length > 0) {
267+
if (!supportsResourcesProperly && enabledResourceFallbackTools.length > 0) {
267268
server.server.sendLoggingMessage({
268269
level: 'info',
269-
data: `Client "${clientVersion?.name}" has known resource issues. Registering ${enabledResourceFallbackTools.length} resource fallback tools`
270+
data: `Client "${clientVersion?.name}" may need resource fallback tools. Registering ${enabledResourceFallbackTools.length} resource fallback tools`
270271
});
271272

272273
enabledResourceFallbackTools.forEach((tool) => {

0 commit comments

Comments
 (0)