feat: support Standard Schema for tool/prompt schemas (#1689)

Co-authored-by: Matt Carey <mcarey@cloudflare.com>
This commit is contained in:
Felix Weinberger 2026-03-23 14:44:38 +00:00 • committed by GitHub
commit 0784be1a67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1327 additions and 212 deletions

View file

@ -0,0 +1,28 @@
#!/usr/bin/env node
/**
* Minimal MCP server using ArkType for schema validation.
* ArkType implements the Standard Schema spec with built-in JSON Schema conversion.
*/
import { McpServer, StdioServerTransport } from '@modelcontextprotocol/server';
import { type } from 'arktype';
const server = new McpServer({
name: 'arktype-example',
version: '1.0.0'
});
// Register a tool with ArkType schema
server.registerTool(
'greet',
{
description: 'Generate a greeting',
inputSchema: type({ name: 'string' })
},
async ({ name }) => ({
content: [{ type: 'text', text: `Hello, ${name}!` }]
})
);
const transport = new StdioServerTransport();
await server.connect(transport);

View file

@ -0,0 +1,30 @@
#!/usr/bin/env node
/**
* Minimal MCP server using Valibot for schema validation.
* Use toStandardJsonSchema() from @valibot/to-json-schema to create
* StandardJSONSchemaV1-compliant schemas.
*/
import { McpServer, StdioServerTransport } from '@modelcontextprotocol/server';
import { toStandardJsonSchema } from '@valibot/to-json-schema';
import * as v from 'valibot';
const server = new McpServer({
name: 'valibot-example',
version: '1.0.0'
});
// Register a tool with Valibot schema
server.registerTool(
'greet',
{
description: 'Generate a greeting',
inputSchema: toStandardJsonSchema(v.object({ name: v.string() }))
},
async ({ name }) => ({
content: [{ type: 'text', text: `Hello, ${name}!` }]
})
);
const transport = new StdioServerTransport();
await server.connect(transport);