mcp-agent-broker 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/app.js +30 -0
- package/dist/infrastructure/db/index.js +44 -0
- package/dist/infrastructure/db/schema.js +136 -0
- package/dist/infrastructure/redis/index.js +11 -0
- package/dist/modules/event/event.service.js +36 -0
- package/dist/modules/identity/agent.service.js +56 -0
- package/dist/modules/lease/lease.service.js +76 -0
- package/dist/modules/task/task.service.js +40 -0
- package/dist/transport/mcp/index.js +157 -0
- package/dist/workers/outbox-relay.js +57 -0
- package/docker-compose.yml +41 -0
- package/drizzle.config.ts +10 -0
- package/package.json +35 -0
- package/src/app.ts +31 -0
- package/src/infrastructure/db/index.ts +10 -0
- package/src/infrastructure/db/migrations/0000_flawless_vanisher.sql +103 -0
- package/src/infrastructure/db/migrations/0001_fearless_sersi.sql +36 -0
- package/src/infrastructure/db/migrations/meta/0000_snapshot.json +714 -0
- package/src/infrastructure/db/migrations/meta/0001_snapshot.json +947 -0
- package/src/infrastructure/db/migrations/meta/_journal.json +20 -0
- package/src/infrastructure/db/schema.ts +148 -0
- package/src/infrastructure/redis/index.ts +7 -0
- package/src/modules/event/event.service.ts +50 -0
- package/src/modules/identity/agent.service.ts +58 -0
- package/src/modules/lease/lease.service.ts +89 -0
- package/src/modules/task/task.service.ts +46 -0
- package/src/transport/mcp/index.ts +167 -0
- package/src/workers/outbox-relay.ts +61 -0
- package/test_client.ts +34 -0
- package/test_task.ts +68 -0
- package/tsconfig.json +14 -0
package/test_task.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
3
|
+
import { CallToolResultSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
import { randomUUID } from "crypto";
|
|
5
|
+
|
|
6
|
+
async function run() {
|
|
7
|
+
const transport = new SSEClientTransport(new URL("http://127.0.0.1:3000/mcp/sse"));
|
|
8
|
+
const client = new Client({ name: "test-client", version: "1.0.0" }, { capabilities: {} });
|
|
9
|
+
|
|
10
|
+
await client.connect(transport);
|
|
11
|
+
console.log("Connected to MCP Server");
|
|
12
|
+
|
|
13
|
+
// 1. Register Agent
|
|
14
|
+
const regResult = await client.request(
|
|
15
|
+
{
|
|
16
|
+
method: "tools/call",
|
|
17
|
+
params: {
|
|
18
|
+
name: "register_agent",
|
|
19
|
+
arguments: { name: "Implementer Agent", version: "1.0", capabilities: ["execute"] }
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
CallToolResultSchema
|
|
23
|
+
);
|
|
24
|
+
const agentInstanceId = (regResult.content[0] as any).text.split("Instance ID: ")[1];
|
|
25
|
+
console.log("1. Agent registered:", agentInstanceId);
|
|
26
|
+
|
|
27
|
+
// 2. Create Task
|
|
28
|
+
const workspaceId = randomUUID(); // Fake for testing
|
|
29
|
+
const repositoryId = randomUUID(); // Fake for testing
|
|
30
|
+
|
|
31
|
+
const createTaskResult = await client.request(
|
|
32
|
+
{
|
|
33
|
+
method: "tools/call",
|
|
34
|
+
params: {
|
|
35
|
+
name: "create_task",
|
|
36
|
+
arguments: {
|
|
37
|
+
workspaceId, repositoryId,
|
|
38
|
+
objective: "Implement a new login endpoint",
|
|
39
|
+
description: "Follow the design docs.",
|
|
40
|
+
createdBy: randomUUID()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
CallToolResultSchema
|
|
45
|
+
);
|
|
46
|
+
const taskId = (createTaskResult.content[0] as any).text.split("Task ID: ")[1];
|
|
47
|
+
console.log("2. Task created:", taskId);
|
|
48
|
+
|
|
49
|
+
// 3. Acquire Lease
|
|
50
|
+
const leaseResult = await client.request(
|
|
51
|
+
{
|
|
52
|
+
method: "tools/call",
|
|
53
|
+
params: {
|
|
54
|
+
name: "acquire_task_lease",
|
|
55
|
+
arguments: {
|
|
56
|
+
taskId, workspaceId, agentInstanceId,
|
|
57
|
+
leaseType: "execution"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
CallToolResultSchema
|
|
62
|
+
);
|
|
63
|
+
console.log("3. Lease acquired:", (leaseResult.content[0] as any).text);
|
|
64
|
+
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
run().catch(console.error);
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "Node16",
|
|
5
|
+
"moduleResolution": "Node16",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"rootDir": "./src"
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"]
|
|
14
|
+
}
|