@agnt-id/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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/server.js ADDED
@@ -0,0 +1,151 @@
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 { z } from "zod";
5
+ const GATEWAY = process.env.AGNT_GATEWAY ?? "https://api.agnt.id";
6
+ const DEFAULT_CHAIN = process.env.AGNT_CHAIN ?? "eip155:1";
7
+ // ── Helpers ──────────────────────────────────────────────────────
8
+ function ensureSuffix(name) {
9
+ const n = name.trim().toLowerCase();
10
+ return n.endsWith(".agnt") ? n : `${n}.agnt`;
11
+ }
12
+ async function gw(path) {
13
+ const res = await fetch(`${GATEWAY}${path}`);
14
+ if (res.status === 404)
15
+ return null;
16
+ if (!res.ok)
17
+ throw new Error(`gateway ${res.status}: ${await res.text()}`);
18
+ return res.json();
19
+ }
20
+ function json(data) {
21
+ return [{ type: "text", text: JSON.stringify(data, null, 2) }];
22
+ }
23
+ // ── Server ───────────────────────────────────────────────────────
24
+ const server = new McpServer({
25
+ name: "agnt",
26
+ version: "0.1.0",
27
+ });
28
+ // Tool: resolve_agnt
29
+ server.tool("resolve_agnt", "Resolve a .agnt name to its wallet, agent endpoints (A2A/MCP), identity records, and metadata. Returns null if the name is not registered.", {
30
+ name: z
31
+ .string()
32
+ .describe("The .agnt name or label (e.g. 'alice' or 'alice.agnt')"),
33
+ }, async ({ name }) => {
34
+ const data = await gw(`/v1/agnt/gateway/resolve/${encodeURIComponent(ensureSuffix(name))}`);
35
+ if (!data) {
36
+ return {
37
+ content: [
38
+ { type: "text", text: `${ensureSuffix(name)} is not registered.` },
39
+ ],
40
+ };
41
+ }
42
+ return { content: json(data) };
43
+ });
44
+ // Tool: reverse_agnt
45
+ server.tool("reverse_agnt", "Look up the primary .agnt name for an EVM address. Returns null if no reverse record is set.", {
46
+ address: z.string().describe("EVM address (0x...)"),
47
+ chain_id: z
48
+ .string()
49
+ .optional()
50
+ .describe("CAIP-2 chain ID (default: eip155:1)"),
51
+ }, async ({ address, chain_id }) => {
52
+ const chain = chain_id ?? DEFAULT_CHAIN;
53
+ const data = await gw(`/v1/agnt/gateway/reverse/${chain}/${address}`);
54
+ if (!data) {
55
+ return {
56
+ content: [
57
+ {
58
+ type: "text",
59
+ text: `No .agnt name found for ${address} on ${chain}.`,
60
+ },
61
+ ],
62
+ };
63
+ }
64
+ return { content: json(data) };
65
+ });
66
+ // Tool: search_agnt
67
+ server.tool("search_agnt", "Search and discover .agnt agents by keyword, skill, or domain. Returns ranked results with trust scores.", {
68
+ q: z.string().optional().describe("Search query"),
69
+ skill: z.string().optional().describe("Filter by OASF skill slug"),
70
+ domain: z.string().optional().describe("Filter by OASF domain slug"),
71
+ chain_id: z
72
+ .string()
73
+ .optional()
74
+ .describe("CAIP-2 chain ID (default: eip155:1)"),
75
+ limit: z.number().optional().describe("Max results (1-50, default: 20)"),
76
+ }, async ({ q, skill, domain, chain_id, limit }) => {
77
+ const url = new URL(`${GATEWAY}/v1/agnt/gateway/discover`);
78
+ url.searchParams.set("chain_id", chain_id ?? DEFAULT_CHAIN);
79
+ if (q)
80
+ url.searchParams.set("q", q);
81
+ if (skill)
82
+ url.searchParams.set("skill", skill);
83
+ if (domain)
84
+ url.searchParams.set("domain", domain);
85
+ if (limit)
86
+ url.searchParams.set("limit", String(limit));
87
+ const res = await fetch(url.toString());
88
+ if (!res.ok)
89
+ throw new Error(`gateway ${res.status}`);
90
+ const data = await res.json();
91
+ return { content: json(data) };
92
+ });
93
+ // Tool: check_availability
94
+ server.tool("check_availability", "Check if a .agnt name is available for registration.", { name: z.string().describe("The .agnt name or label to check") }, async ({ name }) => {
95
+ const full = ensureSuffix(name);
96
+ const data = (await gw(`/v1/agnt/available/${encodeURIComponent(full)}`));
97
+ if (!data) {
98
+ return {
99
+ content: [
100
+ { type: "text", text: `Could not check availability for ${full}.` },
101
+ ],
102
+ };
103
+ }
104
+ const status = data.available ? "available" : "taken";
105
+ return { content: [{ type: "text", text: `${full} is ${status}.` }] };
106
+ });
107
+ // Tool: owner_names
108
+ server.tool("owner_names", "List all .agnt names owned by an EVM address.", {
109
+ address: z.string().describe("EVM address (0x...)"),
110
+ chain_id: z
111
+ .string()
112
+ .optional()
113
+ .describe("CAIP-2 chain ID (default: eip155:1)"),
114
+ limit: z.number().optional().describe("Max results (1-500, default: 100)"),
115
+ }, async ({ address, chain_id, limit }) => {
116
+ const url = new URL(`${GATEWAY}/v1/agnt/gateway/owner/${address}`);
117
+ url.searchParams.set("chain_id", chain_id ?? DEFAULT_CHAIN);
118
+ if (limit)
119
+ url.searchParams.set("limit", String(limit));
120
+ const res = await fetch(url.toString());
121
+ if (!res.ok)
122
+ throw new Error(`gateway ${res.status}`);
123
+ const data = await res.json();
124
+ return { content: json(data) };
125
+ });
126
+ // Tool: trust_score
127
+ server.tool("trust_score", "Get the trust score and reputation signals for a .agnt name.", {
128
+ name: z.string().describe("The .agnt name or label"),
129
+ chain_id: z
130
+ .string()
131
+ .optional()
132
+ .describe("CAIP-2 chain ID (default: eip155:1)"),
133
+ }, async ({ name, chain_id }) => {
134
+ const full = ensureSuffix(name);
135
+ const url = new URL(`${GATEWAY}/v1/agnt/gateway/trust/${encodeURIComponent(full)}`);
136
+ url.searchParams.set("chain_id", chain_id ?? DEFAULT_CHAIN);
137
+ const res = await fetch(url.toString());
138
+ if (!res.ok)
139
+ throw new Error(`gateway ${res.status}`);
140
+ const data = await res.json();
141
+ return { content: json(data) };
142
+ });
143
+ // ── Start ────────────────────────────────────────────────────────
144
+ async function main() {
145
+ const transport = new StdioServerTransport();
146
+ await server.connect(transport);
147
+ }
148
+ main().catch((err) => {
149
+ console.error("agnt-mcp fatal:", err);
150
+ process.exit(1);
151
+ });
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@agnt-id/mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP tool server for resolving .agnt names",
5
+ "type": "module",
6
+ "bin": {
7
+ "agnt-mcp": "dist/server.js"
8
+ },
9
+ "main": "dist/server.js",
10
+ "types": "dist/server.d.ts",
11
+ "files": ["dist", "README.md"],
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "start": "node dist/server.js",
15
+ "prepublishOnly": "tsc"
16
+ },
17
+ "keywords": ["agnt", "mcp", "agent", "naming", "resolve", "model-context-protocol"],
18
+ "license": "MIT",
19
+ "dependencies": {
20
+ "@modelcontextprotocol/sdk": "^1.12.1",
21
+ "zod": "^4.3.6"
22
+ },
23
+ "devDependencies": {
24
+ "typescript": "^5.9.3"
25
+ }
26
+ }