@awcp/mcp 0.0.0-dev-202601300724
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/dist/bin/awcp-mcp.d.ts +29 -0
- package/dist/bin/awcp-mcp.d.ts.map +1 -0
- package/dist/bin/awcp-mcp.js +81 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/server.d.ts +38 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +232 -0
- package/dist/tools/delegate-cancel.d.ts +20 -0
- package/dist/tools/delegate-cancel.d.ts.map +1 -0
- package/dist/tools/delegate-cancel.js +38 -0
- package/dist/tools/delegate-output.d.ts +22 -0
- package/dist/tools/delegate-output.d.ts.map +1 -0
- package/dist/tools/delegate-output.js +44 -0
- package/dist/tools/delegate.d.ts +35 -0
- package/dist/tools/delegate.d.ts.map +1 -0
- package/dist/tools/delegate.js +63 -0
- package/package.json +37 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AWCP MCP Server CLI
|
|
4
|
+
*
|
|
5
|
+
* Starts an MCP server that provides AWCP delegation tools.
|
|
6
|
+
* Connects to a running Delegator Daemon.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* awcp-mcp [--daemon-url URL]
|
|
10
|
+
*
|
|
11
|
+
* Options:
|
|
12
|
+
* --daemon-url URL of Delegator Daemon (default: http://localhost:3100)
|
|
13
|
+
* --help Show this help message
|
|
14
|
+
*
|
|
15
|
+
* Example:
|
|
16
|
+
* awcp-mcp --daemon-url http://localhost:3100
|
|
17
|
+
*
|
|
18
|
+
* Claude Desktop config (claude_desktop_config.json):
|
|
19
|
+
* {
|
|
20
|
+
* "mcpServers": {
|
|
21
|
+
* "awcp": {
|
|
22
|
+
* "command": "npx",
|
|
23
|
+
* "args": ["awcp-mcp", "--daemon-url", "http://localhost:3100"]
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
*/
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=awcp-mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"awcp-mcp.d.ts","sourceRoot":"","sources":["../../src/bin/awcp-mcp.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AWCP MCP Server CLI
|
|
4
|
+
*
|
|
5
|
+
* Starts an MCP server that provides AWCP delegation tools.
|
|
6
|
+
* Connects to a running Delegator Daemon.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* awcp-mcp [--daemon-url URL]
|
|
10
|
+
*
|
|
11
|
+
* Options:
|
|
12
|
+
* --daemon-url URL of Delegator Daemon (default: http://localhost:3100)
|
|
13
|
+
* --help Show this help message
|
|
14
|
+
*
|
|
15
|
+
* Example:
|
|
16
|
+
* awcp-mcp --daemon-url http://localhost:3100
|
|
17
|
+
*
|
|
18
|
+
* Claude Desktop config (claude_desktop_config.json):
|
|
19
|
+
* {
|
|
20
|
+
* "mcpServers": {
|
|
21
|
+
* "awcp": {
|
|
22
|
+
* "command": "npx",
|
|
23
|
+
* "args": ["awcp-mcp", "--daemon-url", "http://localhost:3100"]
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
*/
|
|
28
|
+
import { createAwcpMcpServer } from '../server.js';
|
|
29
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
30
|
+
async function main() {
|
|
31
|
+
const args = process.argv.slice(2);
|
|
32
|
+
// Parse arguments
|
|
33
|
+
let daemonUrl = 'http://localhost:3100';
|
|
34
|
+
for (let i = 0; i < args.length; i++) {
|
|
35
|
+
if (args[i] === '--daemon-url' && args[i + 1]) {
|
|
36
|
+
daemonUrl = args[i + 1];
|
|
37
|
+
i++;
|
|
38
|
+
}
|
|
39
|
+
else if (args[i] === '--help' || args[i] === '-h') {
|
|
40
|
+
console.error(`AWCP MCP Server
|
|
41
|
+
|
|
42
|
+
Provides MCP tools for workspace delegation:
|
|
43
|
+
- delegate: Delegate a local directory to a remote Executor
|
|
44
|
+
- delegate_output: Get delegation status/results
|
|
45
|
+
- delegate_cancel: Cancel active delegations
|
|
46
|
+
|
|
47
|
+
Usage:
|
|
48
|
+
awcp-mcp [options]
|
|
49
|
+
|
|
50
|
+
Options:
|
|
51
|
+
--daemon-url URL Delegator Daemon URL (default: http://localhost:3100)
|
|
52
|
+
--help, -h Show this help message
|
|
53
|
+
|
|
54
|
+
Example:
|
|
55
|
+
awcp-mcp --daemon-url http://localhost:3100
|
|
56
|
+
|
|
57
|
+
Claude Desktop config:
|
|
58
|
+
{
|
|
59
|
+
"mcpServers": {
|
|
60
|
+
"awcp": {
|
|
61
|
+
"command": "npx",
|
|
62
|
+
"args": ["awcp-mcp", "--daemon-url", "http://localhost:3100"]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`);
|
|
67
|
+
process.exit(0);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Create server
|
|
71
|
+
const server = createAwcpMcpServer({ daemonUrl });
|
|
72
|
+
// Connect via stdio
|
|
73
|
+
const transport = new StdioServerTransport();
|
|
74
|
+
await server.connect(transport);
|
|
75
|
+
// Log to stderr (stdout is for MCP protocol)
|
|
76
|
+
console.error(`[AWCP MCP] Server started, connected to daemon at ${daemonUrl}`);
|
|
77
|
+
}
|
|
78
|
+
main().catch((error) => {
|
|
79
|
+
console.error('[AWCP MCP] Fatal error:', error);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @awcp/mcp - MCP tools for AWCP workspace delegation
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { createAwcpMcpServer } from '@awcp/mcp';
|
|
7
|
+
* import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
8
|
+
*
|
|
9
|
+
* const server = createAwcpMcpServer({
|
|
10
|
+
* daemonUrl: 'http://localhost:3100',
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* const transport = new StdioServerTransport();
|
|
14
|
+
* await server.connect(transport);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export { createAwcpMcpServer, type AwcpMcpServerOptions } from './server.js';
|
|
18
|
+
export { DelegatorDaemonClient } from '@awcp/sdk/delegator/client';
|
|
19
|
+
export { delegateSchema, type DelegateParams } from './tools/delegate.js';
|
|
20
|
+
export { delegateOutputSchema, type DelegateOutputParams, } from './tools/delegate-output.js';
|
|
21
|
+
export { delegateCancelSchema, type DelegateCancelParams, } from './tools/delegate-cancel.js';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EACL,oBAAoB,EACpB,KAAK,oBAAoB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,oBAAoB,EACpB,KAAK,oBAAoB,GAC1B,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @awcp/mcp - MCP tools for AWCP workspace delegation
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { createAwcpMcpServer } from '@awcp/mcp';
|
|
7
|
+
* import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
8
|
+
*
|
|
9
|
+
* const server = createAwcpMcpServer({
|
|
10
|
+
* daemonUrl: 'http://localhost:3100',
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* const transport = new StdioServerTransport();
|
|
14
|
+
* await server.connect(transport);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export { createAwcpMcpServer } from './server.js';
|
|
18
|
+
export { DelegatorDaemonClient } from '@awcp/sdk/delegator/client';
|
|
19
|
+
// Tool schemas (for external use)
|
|
20
|
+
export { delegateSchema } from './tools/delegate.js';
|
|
21
|
+
export { delegateOutputSchema, } from './tools/delegate-output.js';
|
|
22
|
+
export { delegateCancelSchema, } from './tools/delegate-cancel.js';
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWCP MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Provides MCP tools for AI agents to delegate workspaces to remote Executors.
|
|
5
|
+
*
|
|
6
|
+
* Tools:
|
|
7
|
+
* - delegate: Initiate a workspace delegation
|
|
8
|
+
* - delegate_output: Get delegation status/results
|
|
9
|
+
* - delegate_cancel: Cancel active delegations
|
|
10
|
+
*/
|
|
11
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
12
|
+
export interface AwcpMcpServerOptions {
|
|
13
|
+
/** URL of the Delegator Daemon (default: http://localhost:3100) */
|
|
14
|
+
daemonUrl?: string;
|
|
15
|
+
/** Timeout for daemon requests in ms (default: 30000) */
|
|
16
|
+
timeout?: number;
|
|
17
|
+
/** Default TTL for delegations in seconds (default: 3600) */
|
|
18
|
+
defaultTtl?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create an AWCP MCP Server instance
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { createAwcpMcpServer } from '@awcp/mcp';
|
|
26
|
+
* import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
27
|
+
*
|
|
28
|
+
* const server = createAwcpMcpServer({
|
|
29
|
+
* daemonUrl: 'http://localhost:3100',
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* const transport = new StdioServerTransport();
|
|
33
|
+
* await server.connect(transport);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function createAwcpMcpServer(options?: AwcpMcpServerOptions): McpServer;
|
|
37
|
+
export { DelegatorDaemonClient } from '@awcp/sdk/delegator/client';
|
|
38
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAoBpE,MAAM,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,aA8LrE;AA2DD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWCP MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Provides MCP tools for AI agents to delegate workspaces to remote Executors.
|
|
5
|
+
*
|
|
6
|
+
* Tools:
|
|
7
|
+
* - delegate: Initiate a workspace delegation
|
|
8
|
+
* - delegate_output: Get delegation status/results
|
|
9
|
+
* - delegate_cancel: Cancel active delegations
|
|
10
|
+
*/
|
|
11
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
12
|
+
import { DelegatorDaemonClient } from '@awcp/sdk/delegator/client';
|
|
13
|
+
import { delegateSchema, delegateDescription, } from './tools/delegate.js';
|
|
14
|
+
import { delegateOutputSchema, delegateOutputDescription, } from './tools/delegate-output.js';
|
|
15
|
+
import { delegateCancelSchema, delegateCancelDescription, } from './tools/delegate-cancel.js';
|
|
16
|
+
/**
|
|
17
|
+
* Create an AWCP MCP Server instance
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { createAwcpMcpServer } from '@awcp/mcp';
|
|
22
|
+
* import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
23
|
+
*
|
|
24
|
+
* const server = createAwcpMcpServer({
|
|
25
|
+
* daemonUrl: 'http://localhost:3100',
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* const transport = new StdioServerTransport();
|
|
29
|
+
* await server.connect(transport);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function createAwcpMcpServer(options = {}) {
|
|
33
|
+
const daemonUrl = options.daemonUrl ?? 'http://localhost:3100';
|
|
34
|
+
const timeout = options.timeout ?? 30000;
|
|
35
|
+
const defaultTtl = options.defaultTtl ?? 3600;
|
|
36
|
+
const client = new DelegatorDaemonClient(daemonUrl, { timeout });
|
|
37
|
+
const server = new McpServer({
|
|
38
|
+
name: 'awcp',
|
|
39
|
+
version: '1.0.0',
|
|
40
|
+
});
|
|
41
|
+
// ============================================
|
|
42
|
+
// Tool: delegate
|
|
43
|
+
// ============================================
|
|
44
|
+
server.tool('delegate', delegateDescription, delegateSchema.shape, async (params) => {
|
|
45
|
+
const { description, prompt, workspace_dir, peer_url, ttl_seconds, access_mode, background, } = params;
|
|
46
|
+
try {
|
|
47
|
+
const result = await client.delegate({
|
|
48
|
+
executorUrl: peer_url,
|
|
49
|
+
localDir: workspace_dir,
|
|
50
|
+
task: { description, prompt },
|
|
51
|
+
ttlSeconds: ttl_seconds ?? defaultTtl,
|
|
52
|
+
accessMode: access_mode ?? 'rw',
|
|
53
|
+
});
|
|
54
|
+
const delegationId = result.delegationId;
|
|
55
|
+
if (background) {
|
|
56
|
+
return {
|
|
57
|
+
content: [
|
|
58
|
+
{
|
|
59
|
+
type: 'text',
|
|
60
|
+
text: `Delegation launched in background.
|
|
61
|
+
|
|
62
|
+
Delegation ID: ${delegationId}
|
|
63
|
+
Executor: ${peer_url}
|
|
64
|
+
Workspace: ${workspace_dir}
|
|
65
|
+
Status: running
|
|
66
|
+
|
|
67
|
+
Use \`delegate_output(delegation_id="${delegationId}")\` to check progress or retrieve results.`,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// Sync mode: wait for completion
|
|
73
|
+
const delegation = await client.waitForCompletion(delegationId, 2000, 3600000);
|
|
74
|
+
return {
|
|
75
|
+
content: [
|
|
76
|
+
{
|
|
77
|
+
type: 'text',
|
|
78
|
+
text: formatDelegationResult(delegation),
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return {
|
|
85
|
+
content: [
|
|
86
|
+
{
|
|
87
|
+
type: 'text',
|
|
88
|
+
text: `Delegation failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
isError: true,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
// ============================================
|
|
96
|
+
// Tool: delegate_output
|
|
97
|
+
// ============================================
|
|
98
|
+
server.tool('delegate_output', delegateOutputDescription, delegateOutputSchema.shape, async (params) => {
|
|
99
|
+
const { delegation_id, block, timeout: timeoutSec } = params;
|
|
100
|
+
try {
|
|
101
|
+
let delegation = await client.getDelegation(delegation_id);
|
|
102
|
+
if (block && isRunning(delegation)) {
|
|
103
|
+
const timeoutMs = (timeoutSec ?? 60) * 1000;
|
|
104
|
+
delegation = await client.waitForCompletion(delegation_id, 2000, timeoutMs);
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
content: [
|
|
108
|
+
{
|
|
109
|
+
type: 'text',
|
|
110
|
+
text: formatDelegationStatus(delegation),
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
return {
|
|
117
|
+
content: [
|
|
118
|
+
{
|
|
119
|
+
type: 'text',
|
|
120
|
+
text: `Failed to get delegation: ${error instanceof Error ? error.message : String(error)}`,
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
isError: true,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
// ============================================
|
|
128
|
+
// Tool: delegate_cancel
|
|
129
|
+
// ============================================
|
|
130
|
+
server.tool('delegate_cancel', delegateCancelDescription, delegateCancelSchema.shape, async (params) => {
|
|
131
|
+
const { delegation_id, all } = params;
|
|
132
|
+
try {
|
|
133
|
+
if (all) {
|
|
134
|
+
const list = await client.listDelegations();
|
|
135
|
+
const active = list.delegations.filter((d) => !['completed', 'error', 'cancelled'].includes(d.state));
|
|
136
|
+
for (const d of active) {
|
|
137
|
+
await client.cancelDelegation(d.id);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
content: [
|
|
141
|
+
{
|
|
142
|
+
type: 'text',
|
|
143
|
+
text: `Cancelled ${active.length} delegation${active.length !== 1 ? 's' : ''}.`,
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (!delegation_id) {
|
|
149
|
+
return {
|
|
150
|
+
content: [
|
|
151
|
+
{
|
|
152
|
+
type: 'text',
|
|
153
|
+
text: 'Provide either delegation_id or all=true',
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
isError: true,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
await client.cancelDelegation(delegation_id);
|
|
160
|
+
return {
|
|
161
|
+
content: [
|
|
162
|
+
{
|
|
163
|
+
type: 'text',
|
|
164
|
+
text: `Delegation ${delegation_id} cancelled.`,
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
return {
|
|
171
|
+
content: [
|
|
172
|
+
{
|
|
173
|
+
type: 'text',
|
|
174
|
+
text: `Failed to cancel: ${error instanceof Error ? error.message : String(error)}`,
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
isError: true,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
return server;
|
|
182
|
+
}
|
|
183
|
+
// ============================================
|
|
184
|
+
// Helpers
|
|
185
|
+
// ============================================
|
|
186
|
+
function isRunning(delegation) {
|
|
187
|
+
return ['created', 'invited', 'accepted', 'started', 'running'].includes(delegation.state);
|
|
188
|
+
}
|
|
189
|
+
function formatDelegationResult(delegation) {
|
|
190
|
+
const lines = [
|
|
191
|
+
`Delegation: ${delegation.id}`,
|
|
192
|
+
`Status: ${delegation.state}`,
|
|
193
|
+
];
|
|
194
|
+
if (delegation.state === 'completed' && delegation.result) {
|
|
195
|
+
lines.push('', '--- Result ---', delegation.result.summary);
|
|
196
|
+
if (delegation.result.highlights?.length) {
|
|
197
|
+
lines.push('', 'Highlights:', ...delegation.result.highlights.map((h) => ` - ${h}`));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (delegation.state === 'error' && delegation.error) {
|
|
201
|
+
lines.push('', '--- Error ---', delegation.error.message);
|
|
202
|
+
if (delegation.error.hint) {
|
|
203
|
+
lines.push(`Hint: ${delegation.error.hint}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return lines.join('\n');
|
|
207
|
+
}
|
|
208
|
+
function formatDelegationStatus(delegation) {
|
|
209
|
+
const lines = [
|
|
210
|
+
`Delegation: ${delegation.id}`,
|
|
211
|
+
`Status: ${delegation.state}`,
|
|
212
|
+
`Executor: ${delegation.peerUrl}`,
|
|
213
|
+
`Created: ${delegation.createdAt}`,
|
|
214
|
+
];
|
|
215
|
+
if (isRunning(delegation)) {
|
|
216
|
+
lines.push('', 'Task is still running...');
|
|
217
|
+
}
|
|
218
|
+
else if (delegation.state === 'completed' && delegation.result) {
|
|
219
|
+
lines.push('', '--- Result ---', delegation.result.summary);
|
|
220
|
+
}
|
|
221
|
+
else if (delegation.state === 'error' && delegation.error) {
|
|
222
|
+
lines.push('', '--- Error ---', delegation.error.message);
|
|
223
|
+
if (delegation.error.hint) {
|
|
224
|
+
lines.push(`Hint: ${delegation.error.hint}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else if (delegation.state === 'cancelled') {
|
|
228
|
+
lines.push('', 'Delegation was cancelled.');
|
|
229
|
+
}
|
|
230
|
+
return lines.join('\n');
|
|
231
|
+
}
|
|
232
|
+
export { DelegatorDaemonClient } from '@awcp/sdk/delegator/client';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* delegate_cancel tool - Cancel an active delegation
|
|
3
|
+
*
|
|
4
|
+
* This will terminate the delegation, unmount the remote filesystem,
|
|
5
|
+
* revoke credentials, and clean up resources.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export declare const delegateCancelSchema: z.ZodObject<{
|
|
9
|
+
delegation_id: z.ZodOptional<z.ZodString>;
|
|
10
|
+
all: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
delegation_id?: string | undefined;
|
|
13
|
+
all?: boolean | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
delegation_id?: string | undefined;
|
|
16
|
+
all?: boolean | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export type DelegateCancelParams = z.infer<typeof delegateCancelSchema>;
|
|
19
|
+
export declare const delegateCancelDescription = "Cancel active delegations.\n\n## Parameters\n- **delegation_id** (optional): Specific delegation ID to cancel\n- **all** (optional): Cancel all active delegations\n\n## Usage\nCancel a specific delegation:\n```\ndelegate_cancel(delegation_id: \"dlg_abc123\")\n```\n\nCancel all active delegations:\n```\ndelegate_cancel(all: true)\n```\n\n## Notes\n- Cancellation triggers cleanup: unmount, credential revocation, export removal\n- The Executor will receive a cancellation signal\n";
|
|
20
|
+
//# sourceMappingURL=delegate-cancel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate-cancel.d.ts","sourceRoot":"","sources":["../../src/tools/delegate-cancel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,oBAAoB;;;;;;;;;EAS/B,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,eAAO,MAAM,yBAAyB,seAoBrC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* delegate_cancel tool - Cancel an active delegation
|
|
3
|
+
*
|
|
4
|
+
* This will terminate the delegation, unmount the remote filesystem,
|
|
5
|
+
* revoke credentials, and clean up resources.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export const delegateCancelSchema = z.object({
|
|
9
|
+
delegation_id: z
|
|
10
|
+
.string()
|
|
11
|
+
.optional()
|
|
12
|
+
.describe('Specific delegation ID to cancel'),
|
|
13
|
+
all: z
|
|
14
|
+
.boolean()
|
|
15
|
+
.optional()
|
|
16
|
+
.describe('Cancel all active delegations'),
|
|
17
|
+
});
|
|
18
|
+
export const delegateCancelDescription = `Cancel active delegations.
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
- **delegation_id** (optional): Specific delegation ID to cancel
|
|
22
|
+
- **all** (optional): Cancel all active delegations
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
Cancel a specific delegation:
|
|
26
|
+
\`\`\`
|
|
27
|
+
delegate_cancel(delegation_id: "dlg_abc123")
|
|
28
|
+
\`\`\`
|
|
29
|
+
|
|
30
|
+
Cancel all active delegations:
|
|
31
|
+
\`\`\`
|
|
32
|
+
delegate_cancel(all: true)
|
|
33
|
+
\`\`\`
|
|
34
|
+
|
|
35
|
+
## Notes
|
|
36
|
+
- Cancellation triggers cleanup: unmount, credential revocation, export removal
|
|
37
|
+
- The Executor will receive a cancellation signal
|
|
38
|
+
`;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* delegate_output tool - Retrieve output from a delegation
|
|
3
|
+
*
|
|
4
|
+
* Use this to check status or get results from a background delegation.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export declare const delegateOutputSchema: z.ZodObject<{
|
|
8
|
+
delegation_id: z.ZodString;
|
|
9
|
+
block: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
delegation_id: string;
|
|
13
|
+
block?: boolean | undefined;
|
|
14
|
+
timeout?: number | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
delegation_id: string;
|
|
17
|
+
block?: boolean | undefined;
|
|
18
|
+
timeout?: number | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export type DelegateOutputParams = z.infer<typeof delegateOutputSchema>;
|
|
21
|
+
export declare const delegateOutputDescription = "Retrieve output from a delegation.\n\n## Parameters\n- **delegation_id** (required): Delegation ID from delegate()\n- **block** (optional): Wait for completion if still running\n- **timeout** (optional): Maximum seconds to wait (default: 60)\n\n## Usage\nAfter launching a background delegation:\n```\ndelegate(background: true, ...) \u2192 \"Delegation ID: dlg_abc123...\"\n```\n\nCheck or retrieve results:\n```\ndelegate_output(delegation_id: \"dlg_abc123\")\n```\n\nWait for completion:\n```\ndelegate_output(delegation_id: \"dlg_abc123\", block: true, timeout: 120)\n```\n";
|
|
22
|
+
//# sourceMappingURL=delegate-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate-output.d.ts","sourceRoot":"","sources":["../../src/tools/delegate-output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EAc/B,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,eAAO,MAAM,yBAAyB,skBAsBrC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* delegate_output tool - Retrieve output from a delegation
|
|
3
|
+
*
|
|
4
|
+
* Use this to check status or get results from a background delegation.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export const delegateOutputSchema = z.object({
|
|
8
|
+
delegation_id: z
|
|
9
|
+
.string()
|
|
10
|
+
.describe('The delegation ID returned from delegate()'),
|
|
11
|
+
block: z
|
|
12
|
+
.boolean()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe('Wait for completion if still running'),
|
|
15
|
+
timeout: z
|
|
16
|
+
.number()
|
|
17
|
+
.int()
|
|
18
|
+
.positive()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Maximum seconds to wait when blocking (default: 60)'),
|
|
21
|
+
});
|
|
22
|
+
export const delegateOutputDescription = `Retrieve output from a delegation.
|
|
23
|
+
|
|
24
|
+
## Parameters
|
|
25
|
+
- **delegation_id** (required): Delegation ID from delegate()
|
|
26
|
+
- **block** (optional): Wait for completion if still running
|
|
27
|
+
- **timeout** (optional): Maximum seconds to wait (default: 60)
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
After launching a background delegation:
|
|
31
|
+
\`\`\`
|
|
32
|
+
delegate(background: true, ...) → "Delegation ID: dlg_abc123..."
|
|
33
|
+
\`\`\`
|
|
34
|
+
|
|
35
|
+
Check or retrieve results:
|
|
36
|
+
\`\`\`
|
|
37
|
+
delegate_output(delegation_id: "dlg_abc123")
|
|
38
|
+
\`\`\`
|
|
39
|
+
|
|
40
|
+
Wait for completion:
|
|
41
|
+
\`\`\`
|
|
42
|
+
delegate_output(delegation_id: "dlg_abc123", block: true, timeout: 120)
|
|
43
|
+
\`\`\`
|
|
44
|
+
`;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* delegate tool - Initiate a workspace delegation to a remote Executor
|
|
3
|
+
*
|
|
4
|
+
* This tool allows an AI agent to delegate a local directory to a remote
|
|
5
|
+
* Executor agent for collaborative task execution.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export declare const delegateSchema: z.ZodObject<{
|
|
9
|
+
description: z.ZodString;
|
|
10
|
+
prompt: z.ZodString;
|
|
11
|
+
workspace_dir: z.ZodString;
|
|
12
|
+
peer_url: z.ZodString;
|
|
13
|
+
ttl_seconds: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
access_mode: z.ZodOptional<z.ZodEnum<["ro", "rw"]>>;
|
|
15
|
+
background: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
description: string;
|
|
18
|
+
prompt: string;
|
|
19
|
+
workspace_dir: string;
|
|
20
|
+
peer_url: string;
|
|
21
|
+
ttl_seconds?: number | undefined;
|
|
22
|
+
access_mode?: "ro" | "rw" | undefined;
|
|
23
|
+
background?: boolean | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
description: string;
|
|
26
|
+
prompt: string;
|
|
27
|
+
workspace_dir: string;
|
|
28
|
+
peer_url: string;
|
|
29
|
+
ttl_seconds?: number | undefined;
|
|
30
|
+
access_mode?: "ro" | "rw" | undefined;
|
|
31
|
+
background?: boolean | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
export type DelegateParams = z.infer<typeof delegateSchema>;
|
|
34
|
+
export declare const delegateDescription = "Delegate a local workspace directory to a remote Executor agent.\n\n## Parameters\n- **description** (required): Short task description for logs\n- **prompt** (required): Full task instructions with goals and constraints\n- **workspace_dir** (required): Local directory path to delegate\n- **peer_url** (required): Executor's AWCP endpoint URL\n- **ttl_seconds** (optional): Lease duration (default: 3600)\n- **access_mode** (optional): \"ro\" or \"rw\" (default: \"rw\")\n- **background** (optional): Return immediately if true (default: false)\n\n## Behavior\n- **Sync mode (background=false)**: Waits for task completion, returns final_summary\n- **Async mode (background=true)**: Returns delegation_id immediately\n\n## Example\n```\ndelegate({\n description: \"Fix TypeScript errors\",\n prompt: \"Find and fix all type errors in the src/ directory...\",\n workspace_dir: \"/path/to/project\",\n peer_url: \"http://executor:4001/awcp\",\n background: true\n})\n```\n";
|
|
35
|
+
//# sourceMappingURL=delegate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate.d.ts","sourceRoot":"","sources":["../../src/tools/delegate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;EA+BzB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,eAAO,MAAM,mBAAmB,q9BAyB/B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* delegate tool - Initiate a workspace delegation to a remote Executor
|
|
3
|
+
*
|
|
4
|
+
* This tool allows an AI agent to delegate a local directory to a remote
|
|
5
|
+
* Executor agent for collaborative task execution.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export const delegateSchema = z.object({
|
|
9
|
+
description: z
|
|
10
|
+
.string()
|
|
11
|
+
.describe('Short task description (for logs and listing)'),
|
|
12
|
+
prompt: z
|
|
13
|
+
.string()
|
|
14
|
+
.describe('Full task instructions including goals and constraints'),
|
|
15
|
+
workspace_dir: z
|
|
16
|
+
.string()
|
|
17
|
+
.describe('Local directory path to delegate to the Executor'),
|
|
18
|
+
peer_url: z
|
|
19
|
+
.string()
|
|
20
|
+
.url()
|
|
21
|
+
.describe('URL of the target Executor AWCP endpoint'),
|
|
22
|
+
ttl_seconds: z
|
|
23
|
+
.number()
|
|
24
|
+
.int()
|
|
25
|
+
.positive()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('Lease duration in seconds (default: 3600)'),
|
|
28
|
+
access_mode: z
|
|
29
|
+
.enum(['ro', 'rw'])
|
|
30
|
+
.optional()
|
|
31
|
+
.describe('Access mode: ro (read-only) or rw (read-write, default)'),
|
|
32
|
+
background: z
|
|
33
|
+
.boolean()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe('If true, returns immediately with delegation_id. ' +
|
|
36
|
+
'If false (default), waits for task completion.'),
|
|
37
|
+
});
|
|
38
|
+
export const delegateDescription = `Delegate a local workspace directory to a remote Executor agent.
|
|
39
|
+
|
|
40
|
+
## Parameters
|
|
41
|
+
- **description** (required): Short task description for logs
|
|
42
|
+
- **prompt** (required): Full task instructions with goals and constraints
|
|
43
|
+
- **workspace_dir** (required): Local directory path to delegate
|
|
44
|
+
- **peer_url** (required): Executor's AWCP endpoint URL
|
|
45
|
+
- **ttl_seconds** (optional): Lease duration (default: 3600)
|
|
46
|
+
- **access_mode** (optional): "ro" or "rw" (default: "rw")
|
|
47
|
+
- **background** (optional): Return immediately if true (default: false)
|
|
48
|
+
|
|
49
|
+
## Behavior
|
|
50
|
+
- **Sync mode (background=false)**: Waits for task completion, returns final_summary
|
|
51
|
+
- **Async mode (background=true)**: Returns delegation_id immediately
|
|
52
|
+
|
|
53
|
+
## Example
|
|
54
|
+
\`\`\`
|
|
55
|
+
delegate({
|
|
56
|
+
description: "Fix TypeScript errors",
|
|
57
|
+
prompt: "Find and fix all type errors in the src/ directory...",
|
|
58
|
+
workspace_dir: "/path/to/project",
|
|
59
|
+
peer_url: "http://executor:4001/awcp",
|
|
60
|
+
background: true
|
|
61
|
+
})
|
|
62
|
+
\`\`\`
|
|
63
|
+
`;
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@awcp/mcp",
|
|
3
|
+
"version": "0.0.0-dev-202601300724",
|
|
4
|
+
"description": "MCP tools for AWCP delegation",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"awcp-mcp": "dist/bin/awcp-mcp.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"dev": "tsc --watch",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"test:watch": "vitest"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@awcp/sdk": "0.0.0-dev-202601300724",
|
|
25
|
+
"@awcp/core": "0.0.0-dev-202601300724",
|
|
26
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
27
|
+
"zod": "^3.23.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^20.12.0",
|
|
31
|
+
"typescript": "^5.4.0",
|
|
32
|
+
"vitest": "^1.4.0"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
]
|
|
37
|
+
}
|