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
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { AgentDispatchError, type DispatchRequest, type RuntimeProfile, type RuntimeService } from "@agent-dispatch/core";
import packageJson from "../package.json" with { type: "json" };
import { mcpToolSchemas } from "./schemas.js";

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

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

Expand Down
4 changes: 2 additions & 2 deletions src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const taskIdInputSchema = z.object({

export const getTaskLogsInputSchema = z.object({
task_id: z.string(),
cursor: z.number().optional(),
limit: z.number().optional()
cursor: z.number().int().nonnegative().optional(),
limit: z.number().int().positive().max(64_000).optional()
});

export const mcpToolSchemas = {
Expand Down
14 changes: 13 additions & 1 deletion test/schemas.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { dispatchTaskInputSchema, mcpToolSchemas, spawnCloudAgentInputSchema } from "../src/index.js";
import { dispatchTaskInputSchema, getTaskLogsInputSchema, mcpToolSchemas, spawnCloudAgentInputSchema } from "../src/index.js";

describe("MCP schemas", () => {
it("keeps dispatch_task provider-neutral", () => {
Expand Down Expand Up @@ -49,4 +49,16 @@ describe("MCP schemas", () => {
runtime_tools: { enabled: ["web-search"] }
});
});

it("constrains get_task_logs cursor and limit", () => {
expect(getTaskLogsInputSchema.parse({ task_id: "task_1", cursor: 0, limit: 64_000 })).toMatchObject({
task_id: "task_1",
cursor: 0,
limit: 64_000
});
expect(() => getTaskLogsInputSchema.parse({ task_id: "task_1", cursor: -1 })).toThrow();
expect(() => getTaskLogsInputSchema.parse({ task_id: "task_1", cursor: 1.5 })).toThrow();
expect(() => getTaskLogsInputSchema.parse({ task_id: "task_1", limit: 0 })).toThrow();
expect(() => getTaskLogsInputSchema.parse({ task_id: "task_1", limit: 64_001 })).toThrow();
});
});
Loading