-
Notifications
You must be signed in to change notification settings - Fork 725
Open
Labels
area: sdkSDK improvements unrelated to MCP specificationSDK improvements unrelated to MCP specification
Description
Problem
The mcp-go framework only returns predefined resources during the resources/list phase.
Expected
It would be highly beneficial if the resources/list phase could support dynamic queries to a database (or other data sources) and return dynamically generated resources, rather than relying solely on predefined configurations.
Example
The following code demonstrates how to dynamically query table names from a PostgreSQL database and return them as resources list
server.setRequestHandler(ListResourcesRequestSchema, async () => {
const client = await pool.connect();
try {
const result = await client.query(
"SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'",
);
return {
resources: result.rows.map((row) => ({
uri: new URL(`${row.table_name}/${SCHEMA_PATH}`, resourceBaseUrl).href,
mimeType: "application/json",
name: `"${row.table_name}" database schema`,
})),
};
} finally {
client.release();
}
});
Metadata
Metadata
Assignees
Labels
area: sdkSDK improvements unrelated to MCP specificationSDK improvements unrelated to MCP specification