{"record":{"id":"667db86b65acbac9","repo":"apache/shardingsphere","slug":"database-s-is-not-configured","errorCode":null,"errorMessage":"Database `%s` is not configured.","messagePattern":"Database `(.+?)` is not configured\\.","errorType":"exception","errorClass":"MCPUnavailableException","httpStatus":null,"severity":"error","filePath":"mcp/core/src/main/java/org/apache/shardingsphere/mcp/core/workflow/WorkflowProxyQueryService.java","lineNumber":97,"sourceCode":"    }\n    \n    @Override\n    public boolean isSameIdentifier(final String databaseName, final IdentifierScope identifierScope, final String identifier, final String existingIdentifier) {\n        return WorkflowSQLUtils.isSameIdentifier(getDatabaseCapability(databaseName).getIdentifierContext(), identifierScope, identifier, existingIdentifier);\n    }\n    \n    private MCPDatabaseQueryFailedException createQueryFailedException(final String databaseName, final SQLException cause) {\n        Optional<MCPDatabaseCapability> databaseCapability = databaseCapabilityProvider.provide(databaseName);\n        MCPJDBCErrorCategory category = databaseCapability.isPresent()\n                ? MCPJDBCExceptionClassifier.classify(databaseCapability.get().getDatabaseType(), cause)\n                : MCPJDBCExceptionClassifier.classify(cause);\n        return new MCPDatabaseQueryFailedException(category, cause);\n    }\n    \n    private Connection openConnection(final String databaseName) throws SQLException {\n        RuntimeDatabaseConfiguration runtimeDatabaseConfig = sessionManager.getTransactionResourceManager().getRuntimeDatabases().get(databaseName);\n        if (null == runtimeDatabaseConfig) {\n            throw new MCPUnavailableException(String.format(\"Database `%s` is not configured.\", databaseName));\n        }\n        return runtimeDatabaseConfig.openConnection(databaseName);\n    }\n    \n    private MCPDatabaseCapability getDatabaseCapability(final String databaseName) {\n        return databaseCapabilityProvider.provide(WorkflowSQLUtils.normalizeIdentifier(databaseName)).orElseThrow(DatabaseCapabilityNotFoundException::new);\n    }\n    \n    private List<Map<String, Object>> extractRows(final ResultSet resultSet) throws SQLException {\n        ResultSetMetaData resultSetMetaData = resultSet.getMetaData();\n        List<Map<String, Object>> result = new LinkedList<>();\n        while (resultSet.next()) {\n            Map<String, Object> row = new LinkedHashMap<>(resultSetMetaData.getColumnCount(), 1F);\n            for (int index = 1; index <= resultSetMetaData.getColumnCount(); index++) {\n                row.put(resultSetMetaData.getColumnLabel(index).toLowerCase(Locale.ENGLISH), resultSet.getObject(index));\n            }\n            result.add(row);\n        }","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/mcp/core/src/main/java/org/apache/shardingsphere/mcp/core/workflow/WorkflowProxyQueryService.java#L79-L115","documentation":"Thrown by WorkflowProxyQueryService.openConnection when the requested database name has no entry in the transaction resource manager's runtime database map. It means the MCP session is not bound to any configured database by that name, so no connection can be opened; MCPUnavailableException is a configuration/availability error, not a query failure.","triggerScenarios":"Calling a workflow query/apply tool with databaseName that is not a registered storage database in the current ShardingSphere instance — a typo, a logical database name that was never created, or a database configured in a different instance than the one the MCP server is attached to.","commonSituations":"Misspelled database name (case or underscore mismatch), querying a database that exists in another environment/proxy, a database created after the MCP session snapshot was taken, or connecting the MCP server to a fresh instance before storage units are registered.","solutions":["List the configured databases on the connected instance (e.g. SHOW DATABASES / the instance's registration tool) and use the exact name.","Verify the MCP server points at the ShardingSphere instance (proxy/JDBC runtime) that actually has the database configured.","If the database was recently registered, re-establish or refresh the MCP session so runtime database metadata is reloaded, then retry."],"exampleFix":"// before\ntoolArguments.put(\"database\", \"sales_db\");\n// after\ntoolArguments.put(\"database\", \"salesdb\"); // exact name as registered on the instance","handlingStrategy":"validation","validationCode":"if (!sessionManager.getTransactionResourceManager().getRuntimeDatabases().containsKey(databaseName)) {\n    // list configured databases and fail fast with a clear message before calling the tool\n}","typeGuard":"const dbConfigured = name => configuredDatabases.includes(name); // populate from a SHOW DATABASES equivalent","tryCatchPattern":"try {\n    queryService.query(databaseName, sql);\n} catch (final MCPUnavailableException ex) {\n    // re-check database registration; surface 'Database `X` is not configured.' to the user\n}","preventionTips":["Fetch the live database list at session start and validate names against it","Use exact registered names (watch case and separators)","Refresh the MCP session after registering new databases"],"tags":["mcp","workflow","database-configuration","connection"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}