Skip to content

Schema Resources

The schema resources module exposes tool input and output JSON schemas as MCP resources. This enables MCP clients to discover the shape of tool parameters and return values via resources/list and resources/read.

Import

import {
  registerToolSchemaResourcesOnMcpServer,
  McpToolSchemaResourcesConfig,
  McpToolSchemaDescriptor,
} from "@modernpath/agent-framework";

registerToolSchemaResourcesOnMcpServer

function registerToolSchemaResourcesOnMcpServer(
  server: McpServer,
  tools: McpToolSchemaDescriptor[],
  config?: McpToolSchemaResourcesConfig,
): void

Registers tool schema resources on an official MCP SDK McpServer instance. Creates an index resource and a per-tool schema resource.

Parameter Type Description
server McpServer An MCP SDK server instance.
tools McpToolSchemaDescriptor[] Array of tool descriptors with schemas.
config McpToolSchemaResourcesConfig Optional configuration for URIs and behavior.

McpToolSchemaResourcesConfig

interface McpToolSchemaResourcesConfig {
  enabled?: boolean;
  indexUri?: string;
  toolUriPrefix?: string;
  mimeType?: string;
}
Property Type Default Description
enabled boolean true When false, no resources are registered.
indexUri string "schema://tools" URI for the index resource listing all tools.
toolUriPrefix string "schema://tools/" Prefix for per-tool schema URIs. The tool name is URI-encoded and appended.
mimeType string "application/json" MIME type for schema resources.

Resource URIs

Index Resource

URI: schema://tools

Returns a JSON document listing all tool schemas:

{
  "type": "modernpath.toolSchemas.index",
  "indexUri": "schema://tools",
  "toolUriPrefix": "schema://tools/",
  "tools": [
    {
      "name": "getTelemetryBundle",
      "description": "Fetch telemetry data for a building",
      "schemaUri": "schema://tools/getTelemetryBundle",
      "hasInputSchema": true,
      "hasOutputSchema": true
    }
  ]
}

Per-Tool Schema Resource

URI: schema://tools/<toolName>

Returns the input and output schemas for a specific tool:

{
  "type": "modernpath.toolSchemas.tool",
  "name": "getTelemetryBundle",
  "description": "Fetch telemetry data for a building",
  "inputSchema": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
      "buildingId": { "type": "string", "description": "Building identifier" },
      "timeRange": { "type": "string", "description": "Time range (e.g. '24h')" }
    },
    "required": ["buildingId"]
  },
  "outputSchema": {
    "type": "object",
    "properties": {
      "temperature": { "type": "number" },
      "humidity": { "type": "number" }
    }
  }
}

Stateless Handler Integration

The stateless MCP handler (createMcpStatelessHandlerFromToolRegistry) automatically supports resources/list and resources/read without additional configuration. It extracts tool schema descriptors from the registry and serves them as resources.

Code Example

With Official MCP SDK

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import {
  registerToolSchemaResourcesOnMcpServer,
  getToolSchemaDescriptorsFromRegistry,
} from "@modernpath/agent-framework";

const mcpServer = new McpServer({ name: "my-tools", version: "1.0.0" });

// Get tool descriptors from registry
const tools = getToolSchemaDescriptorsFromRegistry(registry);

// Register schema resources
registerToolSchemaResourcesOnMcpServer(mcpServer, tools, {
  enabled: true,
  indexUri: "schema://tools",
  toolUriPrefix: "schema://tools/",
});

Querying Schemas from Client Side

// MCP client discovers available schemas
const resources = await mcpClient.listResources();
// [{ uri: "schema://tools", name: "tools.schema.index" }, ...]

// Read the index
const index = await mcpClient.readResource("schema://tools");
// Lists all tools with schema availability

// Read a specific tool's schema
const schema = await mcpClient.readResource("schema://tools/getTelemetryBundle");
// Returns input and output JSON schemas