agoragentic-mcp 1.2.1 → 1.3.1
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 +94 -84
- package/mcp-server.js +377 -115
- package/package.json +18 -16
- package/scripts/postinstall.js +21 -21
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# agoragentic-mcp
|
|
2
|
-
|
|
3
|
-
`agoragentic-mcp` is a local stdio relay for the live Agoragentic MCP server at `https://agoragentic.com/api/mcp`.
|
|
4
|
-
|
|
5
|
-
That means the npm package mirrors the same live tool, prompt, and resource surface that Agoragentic serves remotely instead of shipping a second handwritten MCP implementation that can drift.
|
|
6
|
-
|
|
7
|
-
## Quick Start
|
|
1
|
+
# agoragentic-mcp
|
|
2
|
+
|
|
3
|
+
`agoragentic-mcp` is a local stdio relay for the live Agoragentic MCP server at `https://agoragentic.com/api/mcp`.
|
|
4
|
+
|
|
5
|
+
That means the npm package mirrors the same live tool, prompt, and resource surface that Agoragentic serves remotely instead of shipping a second handwritten MCP implementation that can drift.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
8
|
|
|
9
9
|
### Claude Desktop
|
|
10
10
|
|
|
@@ -80,80 +80,90 @@ File: `~/.codeium/windsurf/mcp_config.json`
|
|
|
80
80
|
|
|
81
81
|
### Standalone
|
|
82
82
|
|
|
83
|
-
```bash
|
|
84
|
-
npx agoragentic-mcp
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
`
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
-
|
|
108
|
-
- `
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
- `
|
|
120
|
-
- `
|
|
121
|
-
- `
|
|
122
|
-
- `
|
|
123
|
-
- `
|
|
124
|
-
- `
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
##
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
1. `
|
|
141
|
-
2. `
|
|
142
|
-
3. `
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
##
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
83
|
+
```bash
|
|
84
|
+
npx agoragentic-mcp
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Agent Client Protocol
|
|
88
|
+
|
|
89
|
+
ACP-compatible clients can launch the same relay through stdio:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npx agoragentic-mcp --acp
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
ACP mode supports the baseline local session flow (`initialize`, `session/new`, `session/prompt`, `session/cancel`) plus `tools/list`, then forwards `tools/call` to the same live Agoragentic MCP surface.
|
|
96
|
+
|
|
97
|
+
## Environment
|
|
98
|
+
|
|
99
|
+
`AGORAGENTIC_API_KEY`
|
|
100
|
+
|
|
101
|
+
- Optional.
|
|
102
|
+
- When set, the relay forwards `Authorization: Bearer <key>` to the remote MCP server.
|
|
103
|
+
- This unlocks authenticated Agent OS routing, receipt, approval, seller, and legacy vault surfaces when your agent is allowed to see them.
|
|
104
|
+
|
|
105
|
+
`AGORAGENTIC_MCP_URL`
|
|
106
|
+
|
|
107
|
+
- Optional override for self-hosted or staging MCP endpoints.
|
|
108
|
+
- Defaults to `https://agoragentic.com/api/mcp`.
|
|
109
|
+
|
|
110
|
+
## Live Tool Surface
|
|
111
|
+
|
|
112
|
+
The package relays the remote MCP server, so the exact tool list is whatever the live Agoragentic server advertises for your current auth state.
|
|
113
|
+
|
|
114
|
+
Anonymous sessions currently get the public tool set:
|
|
115
|
+
|
|
116
|
+
- `agoragentic_browse_services`
|
|
117
|
+
- `agoragentic_quote_service`
|
|
118
|
+
- `agoragentic_call_service`
|
|
119
|
+
- `agoragentic_edge_receipt`
|
|
120
|
+
- `agoragentic_quote`
|
|
121
|
+
- `agoragentic_search` (compatibility/catalog browsing)
|
|
122
|
+
- `agoragentic_register` (compatibility helper for `POST /api/quickstart`)
|
|
123
|
+
- `agoragentic_categories`
|
|
124
|
+
- `agoragentic_x402_test`
|
|
125
|
+
- `agoragentic_validation_status`
|
|
126
|
+
|
|
127
|
+
Authenticated sessions can expose additional router and vault tools depending on agent state and policy, including:
|
|
128
|
+
|
|
129
|
+
- `agoragentic_execute`
|
|
130
|
+
- `agoragentic_match`
|
|
131
|
+
- `agoragentic_status`
|
|
132
|
+
- `agoragentic_receipt`
|
|
133
|
+
- `agoragentic_invoke` (direct-provider compatibility path)
|
|
134
|
+
- `agoragentic_vault` (legacy inventory path)
|
|
135
|
+
|
|
136
|
+
## Stable x402 Flow
|
|
137
|
+
|
|
138
|
+
The anonymous paid flow is:
|
|
139
|
+
|
|
140
|
+
1. `agoragentic_browse_services`
|
|
141
|
+
2. `agoragentic_quote_service`
|
|
142
|
+
3. `agoragentic_call_service`
|
|
143
|
+
|
|
144
|
+
The first unpaid call returns an MCP payment-required error with the decoded x402 challenge and retry instructions. Retry the same tool call with `payment_signature` to complete the paid execution and receive the JSON result plus `Payment-Receipt`.
|
|
145
|
+
|
|
146
|
+
## Router Flow
|
|
147
|
+
|
|
148
|
+
With an API key set, the router-first flow is:
|
|
149
|
+
|
|
150
|
+
1. `agoragentic_match`
|
|
151
|
+
2. `agoragentic_quote`
|
|
152
|
+
3. `agoragentic_execute`
|
|
153
|
+
|
|
154
|
+
Use `agoragentic_status` and `agoragentic_receipt` for follow-up execution tracking.
|
|
155
|
+
|
|
156
|
+
## What is Agoragentic?
|
|
157
|
+
|
|
158
|
+
Agoragentic is Agent OS for deployed agents and swarms. The MCP surface gives agents a live tool bridge into routing, receipts, stable x402 edge services, Seller OS, and governed deployment/control-plane checks.
|
|
159
|
+
|
|
160
|
+
- Agent OS routing and deployment/control-plane checks for registered agents
|
|
161
|
+
- Stable x402 edge for anonymous paid resources
|
|
162
|
+
- Receipts, policy gates, and validation surfaces around paid execution
|
|
163
|
+
- USDC settlement on Base
|
|
164
|
+
|
|
165
|
+
Learn more at [agoragentic.com](https://agoragentic.com)
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
MIT
|
package/mcp-server.js
CHANGED
|
@@ -1,115 +1,377 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const readline = require('readline');
|
|
5
|
+
const crypto = require('crypto');
|
|
6
|
+
const { version: PACKAGE_VERSION } = require('./package.json');
|
|
7
|
+
|
|
8
|
+
const REMOTE_MCP_URL = process.env.AGORAGENTIC_MCP_URL || 'https://agoragentic.com/api/mcp';
|
|
9
|
+
const API_KEY = process.env.AGORAGENTIC_API_KEY || '';
|
|
10
|
+
const ACP_MODE = process.argv.includes('--acp');
|
|
11
|
+
|
|
12
|
+
const ACP_TOOLS = [
|
|
13
|
+
{
|
|
14
|
+
name: 'agoragentic_execute',
|
|
15
|
+
description: 'Route a task through Agent OS execute() with provider selection, fallback, receipts, and settlement.',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'agoragentic_match',
|
|
19
|
+
description: 'Preview routed providers before execution.',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'agoragentic_quote',
|
|
23
|
+
description: 'Create a bounded quote before paid execution.',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'agoragentic_status',
|
|
27
|
+
description: 'Inspect execution status for an invocation.',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'agoragentic_receipt',
|
|
31
|
+
description: 'Fetch normalized receipt and settlement metadata.',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'agoragentic_browse_services',
|
|
35
|
+
description: 'Browse stable x402 edge resources.',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'agoragentic_call_service',
|
|
39
|
+
description: 'Call a stable x402 edge resource after payment challenge handling.',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'agoragentic_edge_receipt',
|
|
43
|
+
description: 'Inspect x402 edge receipt metadata.',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'agoragentic_x402_test',
|
|
47
|
+
description: 'Exercise the free x402 pipeline canary.',
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
function buildRemoteTransport() {
|
|
52
|
+
const { StreamableHTTPClientTransport } = require('@modelcontextprotocol/sdk/client/streamableHttp.js');
|
|
53
|
+
const headers = {};
|
|
54
|
+
if (API_KEY) {
|
|
55
|
+
headers.Authorization = `Bearer ${API_KEY}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return new StreamableHTTPClientTransport(new URL(REMOTE_MCP_URL), {
|
|
59
|
+
requestInit: {
|
|
60
|
+
headers,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function connectRemoteClient() {
|
|
66
|
+
const { Client } = require('@modelcontextprotocol/sdk/client/index.js');
|
|
67
|
+
const transport = buildRemoteTransport();
|
|
68
|
+
const client = new Client(
|
|
69
|
+
{ name: 'agoragentic-mcp', version: PACKAGE_VERSION },
|
|
70
|
+
{ capabilities: { tools: {}, resources: {}, prompts: {} } }
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
client.onerror = (error) => {
|
|
74
|
+
if (!error) return;
|
|
75
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
76
|
+
console.error(`[agoragentic-mcp] remote client error: ${message}`);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
await client.connect(transport);
|
|
80
|
+
return { client, transport };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function runMcpRelay() {
|
|
84
|
+
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
|
|
85
|
+
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
86
|
+
const {
|
|
87
|
+
CallToolRequestSchema,
|
|
88
|
+
ListToolsRequestSchema,
|
|
89
|
+
ListResourcesRequestSchema,
|
|
90
|
+
ReadResourceRequestSchema,
|
|
91
|
+
ListPromptsRequestSchema,
|
|
92
|
+
GetPromptRequestSchema,
|
|
93
|
+
} = require('@modelcontextprotocol/sdk/types.js');
|
|
94
|
+
|
|
95
|
+
const { client, transport } = await connectRemoteClient();
|
|
96
|
+
|
|
97
|
+
const server = new Server(
|
|
98
|
+
{ name: 'agoragentic', version: PACKAGE_VERSION },
|
|
99
|
+
{ capabilities: { tools: {}, resources: {}, prompts: {} } }
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
server.setRequestHandler(ListToolsRequestSchema, async (request) => {
|
|
103
|
+
return client.listTools(request.params);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
107
|
+
return client.callTool(request.params);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
server.setRequestHandler(ListResourcesRequestSchema, async (request) => {
|
|
111
|
+
return client.listResources(request.params);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
115
|
+
return client.readResource(request.params);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
server.setRequestHandler(ListPromptsRequestSchema, async (request) => {
|
|
119
|
+
return client.listPrompts(request.params);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
123
|
+
return client.getPrompt(request.params);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const stdio = new StdioServerTransport();
|
|
127
|
+
await server.connect(stdio);
|
|
128
|
+
|
|
129
|
+
const shutdown = async (signal) => {
|
|
130
|
+
console.error(`[agoragentic-mcp] shutting down on ${signal}`);
|
|
131
|
+
try {
|
|
132
|
+
await transport.terminateSession();
|
|
133
|
+
} catch {
|
|
134
|
+
// Ignore session teardown failures during local shutdown.
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
await transport.close();
|
|
138
|
+
} catch {
|
|
139
|
+
// Ignore transport close failures during local shutdown.
|
|
140
|
+
}
|
|
141
|
+
process.exit(0);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
process.on('SIGINT', () => {
|
|
145
|
+
void shutdown('SIGINT');
|
|
146
|
+
});
|
|
147
|
+
process.on('SIGTERM', () => {
|
|
148
|
+
void shutdown('SIGTERM');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
console.error(`[agoragentic-mcp] stdio relay ${PACKAGE_VERSION} connected to ${REMOTE_MCP_URL}`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function buildAcpInitializeResult() {
|
|
155
|
+
return {
|
|
156
|
+
protocolVersion: 1,
|
|
157
|
+
agentInfo: {
|
|
158
|
+
name: 'Agoragentic Agent OS',
|
|
159
|
+
version: PACKAGE_VERSION,
|
|
160
|
+
description:
|
|
161
|
+
'Agent OS integrations for deployed agents and swarms: execute-first routing, receipts, x402 edge calls, and Base USDC settlement.',
|
|
162
|
+
homepage: 'https://agoragentic.com',
|
|
163
|
+
},
|
|
164
|
+
agentCapabilities: {
|
|
165
|
+
tools: true,
|
|
166
|
+
streaming: false,
|
|
167
|
+
resources: false,
|
|
168
|
+
prompts: false,
|
|
169
|
+
loadSession: false,
|
|
170
|
+
promptCapabilities: {
|
|
171
|
+
image: false,
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
authMethods: [
|
|
175
|
+
{
|
|
176
|
+
type: 'env',
|
|
177
|
+
name: 'AGORAGENTIC_API_KEY',
|
|
178
|
+
configured: Boolean(API_KEY),
|
|
179
|
+
required: false,
|
|
180
|
+
instructions:
|
|
181
|
+
'Optional for public discovery and x402 edge calls. Required for authenticated execute/match/status/receipt. Create one with POST /api/quickstart and intent=buyer|seller|both.',
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function buildAcpResponse(id, result) {
|
|
188
|
+
return {
|
|
189
|
+
jsonrpc: '2.0',
|
|
190
|
+
id,
|
|
191
|
+
result,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function buildAcpError(id, code, message, data) {
|
|
196
|
+
return {
|
|
197
|
+
jsonrpc: '2.0',
|
|
198
|
+
id,
|
|
199
|
+
error: data ? { code, message, data } : { code, message },
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function writeAcpMessage(message) {
|
|
204
|
+
process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function buildAcpSessionId() {
|
|
208
|
+
return `sess_${crypto.randomBytes(12).toString('hex')}`;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function extractAcpPromptText(content) {
|
|
212
|
+
if (typeof content === 'string') return content;
|
|
213
|
+
if (!Array.isArray(content)) return '';
|
|
214
|
+
return content
|
|
215
|
+
.map((part) => {
|
|
216
|
+
if (!part || typeof part !== 'object') return '';
|
|
217
|
+
if (part.type === 'text' && typeof part.text === 'string') return part.text;
|
|
218
|
+
return '';
|
|
219
|
+
})
|
|
220
|
+
.filter(Boolean)
|
|
221
|
+
.join('\n');
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function buildAcpPromptReply(promptText) {
|
|
225
|
+
const suffix = promptText ? ` Prompt received: ${promptText.slice(0, 240)}` : '';
|
|
226
|
+
return [
|
|
227
|
+
'Agoragentic ACP adapter is a tool bridge, not a code-editing chat agent.',
|
|
228
|
+
'Use tools/list, then tools/call with agoragentic_execute, agoragentic_match, agoragentic_quote, agoragentic_receipt, or stable x402 service tools.',
|
|
229
|
+
suffix,
|
|
230
|
+
]
|
|
231
|
+
.filter(Boolean)
|
|
232
|
+
.join(' ');
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
async function runAcpAdapter() {
|
|
236
|
+
const rl = readline.createInterface({
|
|
237
|
+
input: process.stdin,
|
|
238
|
+
crlfDelay: Infinity,
|
|
239
|
+
terminal: false,
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
let remoteSession = null;
|
|
243
|
+
const acpSessions = new Map();
|
|
244
|
+
|
|
245
|
+
async function getRemoteSession() {
|
|
246
|
+
if (!remoteSession) {
|
|
247
|
+
remoteSession = await connectRemoteClient();
|
|
248
|
+
}
|
|
249
|
+
return remoteSession;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
async function shutdownRemote() {
|
|
253
|
+
if (!remoteSession) return;
|
|
254
|
+
try {
|
|
255
|
+
await remoteSession.transport.terminateSession();
|
|
256
|
+
} catch {
|
|
257
|
+
// Ignore session teardown failures during local shutdown.
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
await remoteSession.transport.close();
|
|
261
|
+
} catch {
|
|
262
|
+
// Ignore transport close failures during local shutdown.
|
|
263
|
+
}
|
|
264
|
+
remoteSession = null;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
process.on('SIGINT', () => {
|
|
268
|
+
void shutdownRemote().finally(() => process.exit(0));
|
|
269
|
+
});
|
|
270
|
+
process.on('SIGTERM', () => {
|
|
271
|
+
void shutdownRemote().finally(() => process.exit(0));
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
console.error(`[agoragentic-mcp] ACP adapter ${PACKAGE_VERSION} ready`);
|
|
275
|
+
|
|
276
|
+
for await (const line of rl) {
|
|
277
|
+
if (!line.trim()) continue;
|
|
278
|
+
|
|
279
|
+
let request;
|
|
280
|
+
try {
|
|
281
|
+
request = JSON.parse(line);
|
|
282
|
+
} catch (error) {
|
|
283
|
+
writeAcpMessage(buildAcpError(null, -32700, 'Invalid JSON-RPC payload'));
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const hasId = Object.prototype.hasOwnProperty.call(request, 'id');
|
|
288
|
+
const id = hasId ? request.id : null;
|
|
289
|
+
|
|
290
|
+
function writeResponse(message) {
|
|
291
|
+
if (hasId) writeAcpMessage(message);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
try {
|
|
295
|
+
if (request.method === 'initialize') {
|
|
296
|
+
writeResponse(buildAcpResponse(id, buildAcpInitializeResult()));
|
|
297
|
+
} else if (request.method === 'session/new') {
|
|
298
|
+
const sessionId = buildAcpSessionId();
|
|
299
|
+
acpSessions.set(sessionId, {
|
|
300
|
+
cwd: request.params?.cwd || process.cwd(),
|
|
301
|
+
createdAt: new Date().toISOString(),
|
|
302
|
+
cancelled: false,
|
|
303
|
+
});
|
|
304
|
+
writeResponse(buildAcpResponse(id, { sessionId }));
|
|
305
|
+
} else if (request.method === 'session/prompt') {
|
|
306
|
+
const sessionId = request.params?.sessionId;
|
|
307
|
+
if (!sessionId || !acpSessions.has(sessionId)) {
|
|
308
|
+
writeResponse(buildAcpError(id, -32602, 'Unknown or missing ACP sessionId'));
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const session = acpSessions.get(sessionId);
|
|
313
|
+
session.cancelled = false;
|
|
314
|
+
const promptText = extractAcpPromptText(request.params?.content);
|
|
315
|
+
const reply = buildAcpPromptReply(promptText);
|
|
316
|
+
|
|
317
|
+
writeAcpMessage({
|
|
318
|
+
jsonrpc: '2.0',
|
|
319
|
+
method: 'session/update',
|
|
320
|
+
params: {
|
|
321
|
+
sessionId,
|
|
322
|
+
update: {
|
|
323
|
+
sessionUpdate: 'agent_message_chunk',
|
|
324
|
+
content: {
|
|
325
|
+
type: 'text',
|
|
326
|
+
text: reply,
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
writeResponse(buildAcpResponse(id, { stopReason: session.cancelled ? 'cancelled' : 'end_turn' }));
|
|
332
|
+
} else if (request.method === 'session/cancel') {
|
|
333
|
+
const sessionId = request.params?.sessionId;
|
|
334
|
+
if (sessionId && acpSessions.has(sessionId)) {
|
|
335
|
+
acpSessions.get(sessionId).cancelled = true;
|
|
336
|
+
}
|
|
337
|
+
writeResponse(buildAcpResponse(id, { ok: true }));
|
|
338
|
+
} else if (request.method === 'tools/list') {
|
|
339
|
+
writeResponse(buildAcpResponse(id, { tools: ACP_TOOLS }));
|
|
340
|
+
} else if (request.method === 'tools/call') {
|
|
341
|
+
const { client } = await getRemoteSession();
|
|
342
|
+
const result = await client.callTool(request.params || {});
|
|
343
|
+
writeResponse(buildAcpResponse(id, result));
|
|
344
|
+
} else if (request.method === 'shutdown') {
|
|
345
|
+
await shutdownRemote();
|
|
346
|
+
writeResponse(buildAcpResponse(id, { ok: true }));
|
|
347
|
+
} else {
|
|
348
|
+
writeResponse(
|
|
349
|
+
buildAcpError(id, -32601, 'Unsupported ACP method', {
|
|
350
|
+
supported_methods: [
|
|
351
|
+
'initialize',
|
|
352
|
+
'session/new',
|
|
353
|
+
'session/prompt',
|
|
354
|
+
'session/cancel',
|
|
355
|
+
'tools/list',
|
|
356
|
+
'tools/call',
|
|
357
|
+
'shutdown',
|
|
358
|
+
],
|
|
359
|
+
})
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
} catch (error) {
|
|
363
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
364
|
+
writeResponse(buildAcpError(id, -32000, message));
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
await shutdownRemote();
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const entrypoint = ACP_MODE ? runAcpAdapter : runMcpRelay;
|
|
372
|
+
|
|
373
|
+
entrypoint().catch((error) => {
|
|
374
|
+
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
375
|
+
console.error(`[agoragentic-mcp] fatal: ${message}`);
|
|
376
|
+
process.exit(1);
|
|
377
|
+
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agoragentic-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"mcpName": "io.github.rhein1/agoragentic",
|
|
5
|
-
"description": "Stdio relay for the live Agoragentic MCP server. Mirrors
|
|
5
|
+
"description": "Stdio relay for the live Agoragentic Agent OS MCP server. Mirrors Agent OS routing, receipt, and x402 edge tools from agoragentic.com/api/mcp.",
|
|
6
6
|
"main": "mcp-server.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"agoragentic-mcp": "mcp-server.js"
|
|
8
|
+
"agoragentic-mcp": "mcp-server.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"start": "node mcp-server.js",
|
|
@@ -16,31 +16,33 @@
|
|
|
16
16
|
"model-context-protocol",
|
|
17
17
|
"agoragentic",
|
|
18
18
|
"ai-agents",
|
|
19
|
-
"
|
|
20
|
-
"agent-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
19
|
+
"agent-os",
|
|
20
|
+
"agent-client-protocol",
|
|
21
|
+
"execute-first",
|
|
22
|
+
"claude",
|
|
23
|
+
"cursor",
|
|
24
|
+
"usdc",
|
|
25
|
+
"base",
|
|
25
26
|
"x402",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
27
|
+
"micro-ecf",
|
|
28
|
+
"agentic-payments",
|
|
29
|
+
"relay",
|
|
30
|
+
"stdio",
|
|
31
|
+
"langchain",
|
|
32
|
+
"crewai"
|
|
31
33
|
],
|
|
32
34
|
"author": "Agoragentic <support@agoragentic.com>",
|
|
33
35
|
"license": "MIT",
|
|
34
36
|
"repository": {
|
|
35
37
|
"type": "git",
|
|
36
|
-
"url": "https://github.com/rhein1/agoragentic-integrations"
|
|
38
|
+
"url": "git+https://github.com/rhein1/agoragentic-integrations.git"
|
|
37
39
|
},
|
|
38
40
|
"homepage": "https://agoragentic.com",
|
|
39
41
|
"bugs": {
|
|
40
42
|
"url": "https://github.com/rhein1/agoragentic-integrations/issues"
|
|
41
43
|
},
|
|
42
44
|
"dependencies": {
|
|
43
|
-
"@modelcontextprotocol/sdk": "^1.27.1"
|
|
45
|
+
"@modelcontextprotocol/sdk": "^1.27.1"
|
|
44
46
|
},
|
|
45
47
|
"engines": {
|
|
46
48
|
"node": ">=18.0.0"
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const BOLD = '\x1b[1m';
|
|
3
|
-
const CYAN = '\x1b[36m';
|
|
4
|
-
const DIM = '\x1b[2m';
|
|
5
|
-
const RESET = '\x1b[0m';
|
|
6
|
-
|
|
7
|
-
console.log(`
|
|
8
|
-
${BOLD}Agoragentic MCP Relay${RESET}
|
|
9
|
-
|
|
10
|
-
${CYAN}npx agoragentic-mcp${RESET}
|
|
11
|
-
|
|
12
|
-
This package starts a local stdio relay to the live Agoragentic MCP server:
|
|
13
|
-
${DIM}https://agoragentic.com/api/mcp${RESET}
|
|
14
|
-
|
|
15
|
-
Optional environment:
|
|
16
|
-
${BOLD}AGORAGENTIC_API_KEY${RESET} Forward a bearer token to unlock authenticated tools
|
|
17
|
-
${BOLD}AGORAGENTIC_MCP_URL${RESET} Override the remote MCP endpoint
|
|
18
|
-
|
|
19
|
-
Docs: ${DIM}https://agoragentic.com/docs.html${RESET}
|
|
20
|
-
MCP: ${DIM}https://agoragentic.com/.well-known/mcp/server.json${RESET}
|
|
21
|
-
x402: ${DIM}https://x402.agoragentic.com/services/index.json${RESET}
|
|
22
|
-
`);
|
|
2
|
+
const BOLD = '\x1b[1m';
|
|
3
|
+
const CYAN = '\x1b[36m';
|
|
4
|
+
const DIM = '\x1b[2m';
|
|
5
|
+
const RESET = '\x1b[0m';
|
|
6
|
+
|
|
7
|
+
console.log(`
|
|
8
|
+
${BOLD}Agoragentic MCP Relay${RESET}
|
|
9
|
+
|
|
10
|
+
${CYAN}npx agoragentic-mcp${RESET}
|
|
11
|
+
|
|
12
|
+
This package starts a local stdio relay to the live Agoragentic MCP server:
|
|
13
|
+
${DIM}https://agoragentic.com/api/mcp${RESET}
|
|
14
|
+
|
|
15
|
+
Optional environment:
|
|
16
|
+
${BOLD}AGORAGENTIC_API_KEY${RESET} Forward a bearer token to unlock authenticated tools
|
|
17
|
+
${BOLD}AGORAGENTIC_MCP_URL${RESET} Override the remote MCP endpoint
|
|
18
|
+
|
|
19
|
+
Docs: ${DIM}https://agoragentic.com/docs.html${RESET}
|
|
20
|
+
MCP: ${DIM}https://agoragentic.com/.well-known/mcp/server.json${RESET}
|
|
21
|
+
x402: ${DIM}https://x402.agoragentic.com/services/index.json${RESET}
|
|
22
|
+
`);
|