Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions packages/mcp/scripts/protocol-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@ import {
StreamableHTTPClientTransport,
} from '@modelcontextprotocol/client';
import { createMcpHandler } from '@modelcontextprotocol/server';
import { readFileSync } from 'node:fs';
import { createTerminal49McpServer } from '../dist/server.js';

const featureMap = JSON.parse(
readFileSync(
new URL('../../../skills/agent-trust/feature-map.json', import.meta.url),
'utf8',
),
);
const expectedToolNames = featureMap.mcpTools.map((tool) => tool.name).sort();

const protocolVersion = process.env.MCP_PROTOCOL_VERSION;
if (!protocolVersion) {
throw new Error('MCP_PROTOCOL_VERSION is required');
Expand Down Expand Up @@ -67,13 +76,10 @@ try {
}

const { tools } = await client.listTools();
if (
tools.length !== 14 ||
!tools.some((tool) => tool.name === 'search_docs') ||
!tools.some((tool) => tool.name === 'whoami')
) {
const toolNames = tools.map((tool) => tool.name).sort();
if (JSON.stringify(toolNames) !== JSON.stringify(expectedToolNames)) {
throw new Error(
`Expected 14 tools including search_docs and whoami over ${protocolVersion}, received ${tools.length}`,
`MCP tools/list differs from skills/agent-trust/feature-map.json over ${protocolVersion}. Expected ${JSON.stringify(expectedToolNames)}, received ${JSON.stringify(toolNames)}`,
);
}

Expand Down
13 changes: 11 additions & 2 deletions packages/mcp/src/protocol-compat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ const MCP_DOCS = readFileSync(
'utf8',
);

const MCP_TOOL_NAMES: string[] = JSON.parse(
readFileSync(
new URL('../../../skills/agent-trust/feature-map.json', import.meta.url),
'utf8',
),
)
.mcpTools.map((tool: { name: string }) => tool.name)
.sort();

function documentedToolSection(toolName: string): string {
const marker = `### \`${toolName}\``;
const start = MCP_DOCS.indexOf(marker);
Expand Down Expand Up @@ -174,7 +183,7 @@ describe('MCP protocol compatibility', () => {
]),
);

expect(tools).toHaveLength(14);
expect(tools.map((tool) => tool.name).sort()).toEqual(MCP_TOOL_NAMES);
for (const tool of tools) {
expect(tool.name.length, tool.name).toBeLessThanOrEqual(64);
expect(tool.inputSchema.properties, tool.name).not.toHaveProperty(
Expand Down Expand Up @@ -306,7 +315,7 @@ describe('MCP protocol compatibility', () => {
client.listResourceTemplates(),
]);

expect(tools).toHaveLength(14);
expect(tools.map((tool) => tool.name).sort()).toEqual(MCP_TOOL_NAMES);
expect(prompts).toHaveLength(3);
expect(resources).toHaveLength(3);
expect(resourceTemplates).toHaveLength(1);
Expand Down
Loading