Skip to content

Commit 710a316

Browse files
committed
Constrain logs schema and sync MCP version
1 parent adad436 commit 710a316

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
22
import { AgentDispatchError, type DispatchRequest, type RuntimeProfile, type RuntimeService } from "@agent-dispatch/core";
3+
import packageJson from "../package.json" with { type: "json" };
34
import { mcpToolSchemas } from "./schemas.js";
45

56
export function createAgentDispatchMcpServer(runtime: RuntimeService): McpServer {
6-
const server = new McpServer({ name: "agentdispatch", version: "0.1.0" });
7+
const server = new McpServer({ name: "agentdispatch", version: packageJson.version });
78

89
server.tool("list_providers", mcpToolSchemas.list_providers.shape, async () => jsonContent(runtime.listProviders()));
910

src/schemas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export const taskIdInputSchema = z.object({
3939

4040
export const getTaskLogsInputSchema = z.object({
4141
task_id: z.string(),
42-
cursor: z.number().optional(),
43-
limit: z.number().optional()
42+
cursor: z.number().int().nonnegative().optional(),
43+
limit: z.number().int().positive().max(64_000).optional()
4444
});
4545

4646
export const mcpToolSchemas = {

test/schemas.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import { dispatchTaskInputSchema, mcpToolSchemas, spawnCloudAgentInputSchema } from "../src/index.js";
2+
import { dispatchTaskInputSchema, getTaskLogsInputSchema, mcpToolSchemas, spawnCloudAgentInputSchema } from "../src/index.js";
33

44
describe("MCP schemas", () => {
55
it("keeps dispatch_task provider-neutral", () => {
@@ -49,4 +49,16 @@ describe("MCP schemas", () => {
4949
runtime_tools: { enabled: ["web-search"] }
5050
});
5151
});
52+
53+
it("constrains get_task_logs cursor and limit", () => {
54+
expect(getTaskLogsInputSchema.parse({ task_id: "task_1", cursor: 0, limit: 64_000 })).toMatchObject({
55+
task_id: "task_1",
56+
cursor: 0,
57+
limit: 64_000
58+
});
59+
expect(() => getTaskLogsInputSchema.parse({ task_id: "task_1", cursor: -1 })).toThrow();
60+
expect(() => getTaskLogsInputSchema.parse({ task_id: "task_1", cursor: 1.5 })).toThrow();
61+
expect(() => getTaskLogsInputSchema.parse({ task_id: "task_1", limit: 0 })).toThrow();
62+
expect(() => getTaskLogsInputSchema.parse({ task_id: "task_1", limit: 64_001 })).toThrow();
63+
});
5264
});

0 commit comments

Comments
 (0)