@ggoldani/agent-passport-mcp 0.1.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/LICENSE +21 -0
- package/README.md +99 -0
- package/build/api-bridge/analytics.d.ts +53 -0
- package/build/api-bridge/analytics.js +13 -0
- package/build/api-bridge/badge.d.ts +16 -0
- package/build/api-bridge/badge.js +9 -0
- package/build/api-bridge/client.d.ts +3 -0
- package/build/api-bridge/client.js +50 -0
- package/build/api-bridge/index.d.ts +2 -0
- package/build/api-bridge/index.js +66 -0
- package/build/api-bridge/search.d.ts +32 -0
- package/build/api-bridge/search.js +26 -0
- package/build/api-bridge/trust-check.d.ts +16 -0
- package/build/api-bridge/trust-check.js +16 -0
- package/build/generated/src/config.d.ts +14 -0
- package/build/generated/src/config.js +39 -0
- package/build/generated/src/generated/meta.d.ts +10 -0
- package/build/generated/src/generated/meta.js +10 -0
- package/build/generated/src/generated/schemas.d.ts +94 -0
- package/build/generated/src/generated/schemas.js +107 -0
- package/build/generated/src/generated/specEntries.d.ts +2 -0
- package/build/generated/src/generated/specEntries.js +33 -0
- package/build/generated/src/generated/typedClient.d.ts +117 -0
- package/build/generated/src/generated/typedClient.js +20 -0
- package/build/generated/src/index.d.ts +2 -0
- package/build/generated/src/index.js +17 -0
- package/build/generated/src/lib/contractInvoke.d.ts +20 -0
- package/build/generated/src/lib/contractInvoke.js +87 -0
- package/build/generated/src/lib/errors.d.ts +15 -0
- package/build/generated/src/lib/errors.js +137 -0
- package/build/generated/src/lib/policy.d.ts +5 -0
- package/build/generated/src/lib/policy.js +8 -0
- package/build/generated/src/lib/redact.d.ts +2 -0
- package/build/generated/src/lib/redact.js +42 -0
- package/build/generated/src/lib/stellarClient.d.ts +10 -0
- package/build/generated/src/lib/stellarClient.js +61 -0
- package/build/generated/src/registerContractTools.d.ts +3 -0
- package/build/generated/src/registerContractTools.js +160 -0
- package/build/generated/src/server.d.ts +3 -0
- package/build/generated/src/server.js +10 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +24 -0
- package/package.json +58 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Horizon, rpc } from "@stellar/stellar-sdk";
|
|
2
|
+
import type { AppConfig } from "../config.js";
|
|
3
|
+
export interface StellarClients {
|
|
4
|
+
horizon: Horizon.Server;
|
|
5
|
+
rpc: rpc.Server;
|
|
6
|
+
networkPassphrase: string;
|
|
7
|
+
runHorizon<T>(operation: Promise<T>, operationName: string): Promise<T>;
|
|
8
|
+
runRpc<T>(operation: Promise<T>, operationName: string): Promise<T>;
|
|
9
|
+
}
|
|
10
|
+
export declare function createStellarClients(config: AppConfig): StellarClients;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Horizon, Networks, rpc } from "@stellar/stellar-sdk";
|
|
2
|
+
import { NetworkError, StellarProtocolError, normalizeStellarError } from "./errors.js";
|
|
3
|
+
const DEFAULT_ENDPOINTS = {
|
|
4
|
+
testnet: {
|
|
5
|
+
horizon: "https://horizon-testnet.stellar.org",
|
|
6
|
+
rpc: "https://soroban-testnet.stellar.org",
|
|
7
|
+
passphrase: Networks.TESTNET
|
|
8
|
+
},
|
|
9
|
+
mainnet: {
|
|
10
|
+
horizon: "https://horizon.stellar.org",
|
|
11
|
+
rpc: "https://soroban.stellar.org",
|
|
12
|
+
passphrase: Networks.PUBLIC
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export function createStellarClients(config) {
|
|
16
|
+
const defaults = DEFAULT_ENDPOINTS[config.network];
|
|
17
|
+
const horizonUrl = config.horizonUrl ?? defaults.horizon;
|
|
18
|
+
const rpcUrl = config.rpcUrl ?? defaults.rpc;
|
|
19
|
+
return {
|
|
20
|
+
horizon: new Horizon.Server(horizonUrl),
|
|
21
|
+
rpc: new rpc.Server(rpcUrl),
|
|
22
|
+
networkPassphrase: config.networkPassphrase ?? defaults.passphrase,
|
|
23
|
+
async runHorizon(operation, operationName) {
|
|
24
|
+
try {
|
|
25
|
+
return await withTimeout(operation, `horizon:${operationName}`, config.requestTimeoutMs);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
const normalized = normalizeStellarError(error);
|
|
29
|
+
if (normalized instanceof StellarProtocolError || normalized instanceof NetworkError) {
|
|
30
|
+
throw normalized;
|
|
31
|
+
}
|
|
32
|
+
throw new NetworkError(`Horizon request failed: ${normalized.message}`);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
async runRpc(operation, operationName) {
|
|
36
|
+
try {
|
|
37
|
+
return await withTimeout(operation, `rpc:${operationName}`, config.requestTimeoutMs);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const normalized = normalizeStellarError(error);
|
|
41
|
+
if (normalized instanceof StellarProtocolError || normalized instanceof NetworkError) {
|
|
42
|
+
throw normalized;
|
|
43
|
+
}
|
|
44
|
+
throw new NetworkError(`Soroban RPC request failed: ${normalized.message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function withTimeout(operation, operationName, timeoutMs) {
|
|
50
|
+
let timeoutId;
|
|
51
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
52
|
+
timeoutId = setTimeout(() => {
|
|
53
|
+
reject(new NetworkError(`${operationName} timed out after ${timeoutMs}ms.`));
|
|
54
|
+
}, timeoutMs);
|
|
55
|
+
});
|
|
56
|
+
return Promise.race([operation, timeoutPromise]).finally(() => {
|
|
57
|
+
if (timeoutId) {
|
|
58
|
+
clearTimeout(timeoutId);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Spec } from "@stellar/stellar-sdk/contract";
|
|
2
|
+
import { invokeContractMethod } from "./lib/contractInvoke.js";
|
|
3
|
+
import { SPEC_ENTRIES } from "./generated/specEntries.js";
|
|
4
|
+
import * as G from "./generated/schemas.js";
|
|
5
|
+
const spec = new Spec([...SPEC_ENTRIES]);
|
|
6
|
+
export function registerContractTools(server, config) {
|
|
7
|
+
server.tool("ap_init", "Soroban contract method `init` (generated).", G.initInputSchema, async (input) => {
|
|
8
|
+
const contractId = input.contractId ?? config.contractId;
|
|
9
|
+
return invokeContractMethod(config, spec, {
|
|
10
|
+
contractId,
|
|
11
|
+
sourceAccount: input.sourceAccount,
|
|
12
|
+
method: "init",
|
|
13
|
+
args: { admin: input.admin, authorized_relayer: input.authorized_relayer }
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
server.tool("ap_get_agent", "Soroban contract method `get_agent` (generated).", G.get_agentInputSchema, async (input) => {
|
|
17
|
+
const contractId = input.contractId ?? config.contractId;
|
|
18
|
+
return invokeContractMethod(config, spec, {
|
|
19
|
+
contractId,
|
|
20
|
+
sourceAccount: input.sourceAccount,
|
|
21
|
+
method: "get_agent",
|
|
22
|
+
args: { owner_address: input.owner_address }
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
server.tool("ap_get_config", "Soroban contract method `get_config` (generated).", G.get_configInputSchema, async (input) => {
|
|
26
|
+
const contractId = input.contractId ?? config.contractId;
|
|
27
|
+
return invokeContractMethod(config, spec, {
|
|
28
|
+
contractId,
|
|
29
|
+
sourceAccount: input.sourceAccount,
|
|
30
|
+
method: "get_config",
|
|
31
|
+
args: {}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
server.tool("ap_get_rating", "Soroban contract method `get_rating` (generated).", G.get_ratingInputSchema, async (input) => {
|
|
35
|
+
const contractId = input.contractId ?? config.contractId;
|
|
36
|
+
return invokeContractMethod(config, spec, {
|
|
37
|
+
contractId,
|
|
38
|
+
sourceAccount: input.sourceAccount,
|
|
39
|
+
method: "get_rating",
|
|
40
|
+
args: { interaction_tx_hash: input.interaction_tx_hash }
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
server.tool("ap_add_relayer", "Soroban contract method `add_relayer` (generated).", G.add_relayerInputSchema, async (input) => {
|
|
44
|
+
const contractId = input.contractId ?? config.contractId;
|
|
45
|
+
return invokeContractMethod(config, spec, {
|
|
46
|
+
contractId,
|
|
47
|
+
sourceAccount: input.sourceAccount,
|
|
48
|
+
method: "add_relayer",
|
|
49
|
+
args: { admin: input.admin, relayer: input.relayer }
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
server.tool("ap_list_agents", "Soroban contract method `list_agents` (generated).", G.list_agentsInputSchema, async (input) => {
|
|
53
|
+
const contractId = input.contractId ?? config.contractId;
|
|
54
|
+
return invokeContractMethod(config, spec, {
|
|
55
|
+
contractId,
|
|
56
|
+
sourceAccount: input.sourceAccount,
|
|
57
|
+
method: "list_agents",
|
|
58
|
+
args: { from: input.from, limit: input.limit }
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
server.tool("ap_accept_admin", "Soroban contract method `accept_admin` (generated).", G.accept_adminInputSchema, async (input) => {
|
|
62
|
+
const contractId = input.contractId ?? config.contractId;
|
|
63
|
+
return invokeContractMethod(config, spec, {
|
|
64
|
+
contractId,
|
|
65
|
+
sourceAccount: input.sourceAccount,
|
|
66
|
+
method: "accept_admin",
|
|
67
|
+
args: { new_admin: input.new_admin }
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
server.tool("ap_get_relayers", "Soroban contract method `get_relayers` (generated).", G.get_relayersInputSchema, async (input) => {
|
|
71
|
+
const contractId = input.contractId ?? config.contractId;
|
|
72
|
+
return invokeContractMethod(config, spec, {
|
|
73
|
+
contractId,
|
|
74
|
+
sourceAccount: input.sourceAccount,
|
|
75
|
+
method: "get_relayers",
|
|
76
|
+
args: {}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
server.tool("ap_submit_rating", "Soroban contract method `submit_rating` (generated).", G.submit_ratingInputSchema, async (input) => {
|
|
80
|
+
const contractId = input.contractId ?? config.contractId;
|
|
81
|
+
return invokeContractMethod(config, spec, {
|
|
82
|
+
contractId,
|
|
83
|
+
sourceAccount: input.sourceAccount,
|
|
84
|
+
method: "submit_rating",
|
|
85
|
+
args: { rating: input.rating }
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
server.tool("ap_register_agent", "Soroban contract method `register_agent` (generated).", G.register_agentInputSchema, async (input) => {
|
|
89
|
+
const contractId = input.contractId ?? config.contractId;
|
|
90
|
+
return invokeContractMethod(config, spec, {
|
|
91
|
+
contractId,
|
|
92
|
+
sourceAccount: input.sourceAccount,
|
|
93
|
+
method: "register_agent",
|
|
94
|
+
args: { owner_address: input.owner_address, input: input.input }
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
server.tool("ap_remove_relayer", "Soroban contract method `remove_relayer` (generated).", G.remove_relayerInputSchema, async (input) => {
|
|
98
|
+
const contractId = input.contractId ?? config.contractId;
|
|
99
|
+
return invokeContractMethod(config, spec, {
|
|
100
|
+
contractId,
|
|
101
|
+
sourceAccount: input.sourceAccount,
|
|
102
|
+
method: "remove_relayer",
|
|
103
|
+
args: { admin: input.admin, relayer: input.relayer }
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
server.tool("ap_transfer_admin", "Soroban contract method `transfer_admin` (generated).", G.transfer_adminInputSchema, async (input) => {
|
|
107
|
+
const contractId = input.contractId ?? config.contractId;
|
|
108
|
+
return invokeContractMethod(config, spec, {
|
|
109
|
+
contractId,
|
|
110
|
+
sourceAccount: input.sourceAccount,
|
|
111
|
+
method: "transfer_admin",
|
|
112
|
+
args: { admin: input.admin, new_admin: input.new_admin }
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
server.tool("ap_update_profile", "Soroban contract method `update_profile` (generated).", G.update_profileInputSchema, async (input) => {
|
|
116
|
+
const contractId = input.contractId ?? config.contractId;
|
|
117
|
+
return invokeContractMethod(config, spec, {
|
|
118
|
+
contractId,
|
|
119
|
+
sourceAccount: input.sourceAccount,
|
|
120
|
+
method: "update_profile",
|
|
121
|
+
args: { owner_address: input.owner_address, input: input.input }
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
server.tool("ap_deregister_agent", "Soroban contract method `deregister_agent` (generated).", G.deregister_agentInputSchema, async (input) => {
|
|
125
|
+
const contractId = input.contractId ?? config.contractId;
|
|
126
|
+
return invokeContractMethod(config, spec, {
|
|
127
|
+
contractId,
|
|
128
|
+
sourceAccount: input.sourceAccount,
|
|
129
|
+
method: "deregister_agent",
|
|
130
|
+
args: { owner_address: input.owner_address }
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
server.tool("ap_register_interaction", "Soroban contract method `register_interaction` (generated).", G.register_interactionInputSchema, async (input) => {
|
|
134
|
+
const contractId = input.contractId ?? config.contractId;
|
|
135
|
+
return invokeContractMethod(config, spec, {
|
|
136
|
+
contractId,
|
|
137
|
+
sourceAccount: input.sourceAccount,
|
|
138
|
+
method: "register_interaction",
|
|
139
|
+
args: { relayer: input.relayer, interaction: input.interaction }
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
server.tool("ap_cancel_admin_transfer", "Soroban contract method `cancel_admin_transfer` (generated).", G.cancel_admin_transferInputSchema, async (input) => {
|
|
143
|
+
const contractId = input.contractId ?? config.contractId;
|
|
144
|
+
return invokeContractMethod(config, spec, {
|
|
145
|
+
contractId,
|
|
146
|
+
sourceAccount: input.sourceAccount,
|
|
147
|
+
method: "cancel_admin_transfer",
|
|
148
|
+
args: { admin: input.admin }
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
server.tool("ap_list_agent_interactions", "Soroban contract method `list_agent_interactions` (generated).", G.list_agent_interactionsInputSchema, async (input) => {
|
|
152
|
+
const contractId = input.contractId ?? config.contractId;
|
|
153
|
+
return invokeContractMethod(config, spec, {
|
|
154
|
+
contractId,
|
|
155
|
+
sourceAccount: input.sourceAccount,
|
|
156
|
+
method: "list_agent_interactions",
|
|
157
|
+
args: { provider_address: input.provider_address, from_seq: input.from_seq, limit: input.limit }
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { registerContractTools } from "./registerContractTools.js";
|
|
3
|
+
export function createServer(config) {
|
|
4
|
+
const server = new McpServer({
|
|
5
|
+
name: "agent-passport-contract",
|
|
6
|
+
version: "0.0.0"
|
|
7
|
+
});
|
|
8
|
+
registerContractTools(server, config);
|
|
9
|
+
return server;
|
|
10
|
+
}
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { loadConfig } from "./generated/src/config.js";
|
|
5
|
+
import { registerContractTools } from "./generated/src/registerContractTools.js";
|
|
6
|
+
import { registerApiBridgeTools } from "./api-bridge/index.js";
|
|
7
|
+
const server = new McpServer({
|
|
8
|
+
name: "agent-passport",
|
|
9
|
+
version: "0.1.0",
|
|
10
|
+
});
|
|
11
|
+
server.tool("health", "Check MCP server status", {}, async () => ({
|
|
12
|
+
content: [{ type: "text", text: "AgentPassport MCP server is running" }],
|
|
13
|
+
}));
|
|
14
|
+
async function main() {
|
|
15
|
+
const config = loadConfig();
|
|
16
|
+
registerContractTools(server, config);
|
|
17
|
+
registerApiBridgeTools(server);
|
|
18
|
+
const transport = new StdioServerTransport();
|
|
19
|
+
await server.connect(transport);
|
|
20
|
+
}
|
|
21
|
+
main().catch((error) => {
|
|
22
|
+
console.error("Fatal error:", error);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ggoldani/agent-passport-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for AgentPassport trust registry — 18 contract tools + 4 REST API bridge tools",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "build/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"agent-passport-mcp": "build/index.js"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./build/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"build",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"start": "node build/index.js",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"prepublishOnly": "npm run build"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
31
|
+
"@stellar/stellar-sdk": "^14.6.1",
|
|
32
|
+
"zod": "^4.3.6"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@ggoldani/stellarmcp": "^0.1.7",
|
|
36
|
+
"@types/node": "^20.0.0",
|
|
37
|
+
"typescript": "^5.0.0"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"mcp",
|
|
41
|
+
"stellar",
|
|
42
|
+
"soroban",
|
|
43
|
+
"agent",
|
|
44
|
+
"trust",
|
|
45
|
+
"reputation",
|
|
46
|
+
"agent-passport",
|
|
47
|
+
"model-context-protocol"
|
|
48
|
+
],
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/ggoldani/agent-passport.git",
|
|
56
|
+
"directory": "tools/agent-passport-mcp"
|
|
57
|
+
}
|
|
58
|
+
}
|