Skip to content

fix(mcp): code review fixes — type-aware dockit schema, error handling, resource notifications - #27

Merged
Blankll merged 8 commits into
masterfrom
feat/mcp-tool-guidance
Aug 11, 2026
Merged

fix(mcp): code review fixes — type-aware dockit schema, error handling, resource notifications#27
Blankll merged 8 commits into
masterfrom
feat/mcp-tool-guidance

Conversation

@Blankll

@Blankll Blankll commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to PR #26. Fixes 3 issues + 1 performance point found in code review.

Issue 1 (Medium): dockit schema resources called non-existent tools

fetchSchemaViaListTables called list_tables + list_columns — sqlkit tool names that don't exist on the dockit bridge. Replaced with type-specific fetchers:

  • Elasticsearch: es__cat_indices + es__get_mapping
  • MongoDB: mongo__list_databases + mongo__list_collections
  • DynamoDB: dynamo__list_tables + dynamo__describe_table

Issue 2 (Low-Medium): sendResourceListChanged() never called

Server advertised resources: { listChanged: true } but never sent the notification. Now onToolsChanged calls both sendToolListChanged() and sendResourceListChanged().

Issue 3 (Low): Resource/completion handlers don't catch errors

Tool handler wraps in try-catch with structured error results, but resource/completion handlers let exceptions propagate. Now:

  • readResource errors return { isError: true } with error text
  • completeArgument errors return { completion: { values: [] } }

Performance: listResources uses cached connections

Was making live HTTP calls (safeListConnections) on every ListResources request. Now uses snapshot.connections from the registry poll cache — zero HTTP calls for resource listing.

Verification

  • 63/63 tests pass
  • Build clean (tsc --noEmit)
  • Lint 0 errors

Ultraworked with Sisyphus

Blankll and others added 8 commits August 10, 2026 14:08
Strengthen tool descriptions so AI agents reach for data_studio__* on any database task (query, schema, row counts) instead of local DB CLIs. get_status and list_connections are now framed as the entry point, every backend tool carries a note to prefer data-studio, and all descriptions ask agents to report results in the user's language (中文/English).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Extend data-studio-mcp beyond plain tools: expose connections and per-connection schema as read-only MCP resources (with a resource template), add explore-database/inspect-table/debug-query prompts, and argument completions for connection_id/database. Every tool now carries a human-readable title and strict input schemas (additionalProperties: false). get_status gains a summary block (connection counts, types, tool distribution) so agents can pick the right connection without extra calls. execute_query results include structuredContent (columns/rows) for lossless consumption.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Add integration tests for the new primitives: resources list/read (connections + schema), resource templates, prompts (explore/inspect/debug), argument completions, and structuredContent on execute_query results. Extend the get_status test to assert the summary block.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…pe clients

fetchSchemaViaListTables: dockit backends don't have get_schema — now uses list_tables + list_columns to build the schema snapshot. completeArgument: respects context.arguments.connection_id instead of always using the first connection. collectConnections: reuses this.clients instead of creating duplicate BackendClient instances on each poll. Updates R1 test stub to exercise the list_tables path.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…rce list notifications

fetchSchemaViaListTables replaced with type-specific fetchers: ES uses es__cat_indices + es__get_mapping, MongoDB uses mongo__list_databases + mongo__list_collections, DynamoDB uses dynamo__list_tables + dynamo__describe_table. listResources now uses cached connections from registry snapshot instead of live HTTP calls. readResource and completeArgument wrapped in try-catch for consistent error handling. onToolsChanged now also sends sendResourceListChanged.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…fetchers

Resolved 3-file conflict: index.ts (keep cached connections + try-catch + sendResourceListChanged), resources.ts (keep type-aware ES/MongoDB/DynamoDB schema fetchers), tests (keep ES-specific stubs). All 63 tests pass.
…detection

fetchMongoSchema/fetchDynamoSchema: dockit bridge wraps responses in ApiResponse {status, message, data}. Added unwrapBridgePayload to handle the double-wrapping. MongoDB returns {databases: [string]} and {collections: [string]} — not arrays of objects. DynamoDB returns {tableNames: [string]} and {attributeDefinitions: [{attributeName, attributeType}]}. extractArray upgraded to handle nested wrappers. Removed non-standard isError field from ReadResourceResult. Registry now detects connection-only changes (connSignature) and fires onToolsChanged → sendResourceListChanged. Added R1b (MongoDB) and R1c (DynamoDB) test cases.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@Blankll
Blankll merged commit 1318773 into master Aug 11, 2026
3 checks passed
@Blankll
Blankll deleted the feat/mcp-tool-guidance branch August 11, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant