@yamo/mcp-server 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/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/index.js +154 -0
- package/dist/integration-test.js +61 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 YAMO Protocol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# 🤖 YAMO Chain MCP Server (v1.0.0 - Protocol v0.4)
|
|
2
|
+
|
|
3
|
+
This MCP Server acts as a bridge, allowing LLMs to interact with the YAMO Blockchain. It is now powered by `@yamo/core` for robust IPFS handling.
|
|
4
|
+
|
|
5
|
+
## 🧰 Tools Provided
|
|
6
|
+
|
|
7
|
+
### `yamo_submit_block`
|
|
8
|
+
Submits a new reasoning block.
|
|
9
|
+
* **Input**: `blockId`, `contentHash`, etc.
|
|
10
|
+
* **New Feature**: `content` (string) and `files` (array). If provided, the server handles IPFS uploading and Deep Bundling automatically before signing.
|
|
11
|
+
* **Encryption**: Optional `encryptionKey` (string). If provided, the bundle is encrypted (AES-256-GCM) before upload, ensuring privacy for sensitive reasoning chains.
|
|
12
|
+
|
|
13
|
+
### `yamo_verify_block`
|
|
14
|
+
Verifies if a specific hash matches the immutable record.
|
|
15
|
+
|
|
16
|
+
## ⚙️ Configuration
|
|
17
|
+
|
|
18
|
+
Add to your Claude Desktop config (`claude_desktop_config.json`):
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"mcpServers": {
|
|
23
|
+
"yamo-chain": {
|
|
24
|
+
"command": "node",
|
|
25
|
+
"args": ["/absolute/path/to/yamo/packages/mcp-server/dist/index.js"],
|
|
26
|
+
"env": {
|
|
27
|
+
"CONTRACT_ADDRESS": "0xe7f1...",
|
|
28
|
+
"RPC_URL": "http://127.0.0.1:8545",
|
|
29
|
+
"PRIVATE_KEY": "0x...",
|
|
30
|
+
"USE_REAL_IPFS": "true",
|
|
31
|
+
"PINATA_JWT": "eyJ..."
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
40
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
41
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
42
|
+
const core_1 = require("@yamo/core");
|
|
43
|
+
const dotenv = __importStar(require("dotenv"));
|
|
44
|
+
const fs_1 = __importDefault(require("fs"));
|
|
45
|
+
dotenv.config();
|
|
46
|
+
const SUBMIT_BLOCK_TOOL = {
|
|
47
|
+
name: "yamo_submit_block",
|
|
48
|
+
description: "Submits a YAMO block to the YAMORegistry smart contract.",
|
|
49
|
+
inputSchema: {
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: {
|
|
52
|
+
blockId: { type: "string" },
|
|
53
|
+
previousBlock: { type: "string" },
|
|
54
|
+
contentHash: { type: "string" },
|
|
55
|
+
consensusType: { type: "string" },
|
|
56
|
+
ledger: { type: "string" },
|
|
57
|
+
content: { type: "string", description: "Optional: Full YAMO text content for IPFS anchoring." },
|
|
58
|
+
encryptionKey: { type: "string", description: "Optional: Key to encrypt the IPFS bundle." },
|
|
59
|
+
files: {
|
|
60
|
+
type: "array",
|
|
61
|
+
items: { type: "object", properties: { name: { type: "string" }, content: { type: "string" } } },
|
|
62
|
+
description: "Optional: Array of output files to bundle. Each file's 'content' can be either the actual file content (string) or a file path (will be auto-read)."
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
required: ["blockId", "previousBlock", "contentHash", "consensusType", "ledger"],
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
const VERIFY_BLOCK_TOOL = {
|
|
69
|
+
name: "yamo_verify_block",
|
|
70
|
+
description: "Verifies a block's content hash.",
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: "object",
|
|
73
|
+
properties: {
|
|
74
|
+
blockId: { type: "string" },
|
|
75
|
+
contentHash: { type: "string" },
|
|
76
|
+
},
|
|
77
|
+
required: ["blockId", "contentHash"],
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
class YamoMcpServer {
|
|
81
|
+
server;
|
|
82
|
+
ipfs;
|
|
83
|
+
chain;
|
|
84
|
+
constructor() {
|
|
85
|
+
this.server = new index_js_1.Server({ name: "yamo", version: "1.0.0" }, { capabilities: { tools: {} } });
|
|
86
|
+
this.ipfs = new core_1.IpfsManager();
|
|
87
|
+
this.chain = new core_1.YamoChainClient();
|
|
88
|
+
this.setupHandlers();
|
|
89
|
+
}
|
|
90
|
+
setupHandlers() {
|
|
91
|
+
this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
|
|
92
|
+
tools: [SUBMIT_BLOCK_TOOL, VERIFY_BLOCK_TOOL],
|
|
93
|
+
}));
|
|
94
|
+
this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
95
|
+
const { name, arguments: args } = request.params;
|
|
96
|
+
try {
|
|
97
|
+
if (name === "yamo_submit_block") {
|
|
98
|
+
const { blockId, previousBlock, contentHash, consensusType, ledger, content, files, encryptionKey } = args;
|
|
99
|
+
// Process files - auto-read if they're file paths
|
|
100
|
+
let processedFiles = files;
|
|
101
|
+
if (files && Array.isArray(files)) {
|
|
102
|
+
processedFiles = files.map((file) => {
|
|
103
|
+
// Check if content is a file path that exists
|
|
104
|
+
if (typeof file.content === 'string' && fs_1.default.existsSync(file.content)) {
|
|
105
|
+
console.error(`Auto-reading file from path: ${file.content}`);
|
|
106
|
+
return {
|
|
107
|
+
name: file.name,
|
|
108
|
+
content: fs_1.default.readFileSync(file.content, 'utf8')
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Otherwise use content as-is
|
|
112
|
+
return file;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
let ipfsCID = undefined;
|
|
116
|
+
if (content) {
|
|
117
|
+
ipfsCID = await this.ipfs.upload({
|
|
118
|
+
content,
|
|
119
|
+
files: processedFiles,
|
|
120
|
+
encryptionKey
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const txHash = await this.chain.submitBlock(blockId, previousBlock, contentHash, consensusType, ledger, ipfsCID);
|
|
124
|
+
return {
|
|
125
|
+
content: [{ type: "text", text: `Block ${blockId} anchored. Tx: ${txHash}. IPFS: ${ipfsCID || "None"}` }],
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (name === "yamo_verify_block") {
|
|
129
|
+
const { blockId, contentHash } = args;
|
|
130
|
+
const contract = this.chain.getContract(false);
|
|
131
|
+
const hashBytes = contentHash.startsWith("0x") ? contentHash : `0x${contentHash}`;
|
|
132
|
+
const isValid = await contract.verifyBlock(blockId, hashBytes);
|
|
133
|
+
return {
|
|
134
|
+
content: [{ type: "text", text: isValid ? "VERIFIED" : "FAILED" }],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
return {
|
|
141
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
142
|
+
isError: true,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
async run() {
|
|
148
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
149
|
+
await this.server.connect(transport);
|
|
150
|
+
console.error("YAMO MCP Server v1.0.0 running on stdio");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const server = new YamoMcpServer();
|
|
154
|
+
server.run().catch(console.error);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/client/index.js");
|
|
7
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/client/stdio.js");
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
async function runTest() {
|
|
10
|
+
const transport = new stdio_js_1.StdioClientTransport({
|
|
11
|
+
command: "node",
|
|
12
|
+
args: ["dist/index.js"],
|
|
13
|
+
env: {
|
|
14
|
+
...process.env,
|
|
15
|
+
CONTRACT_ADDRESS: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
16
|
+
RPC_URL: "http://127.0.0.1:8545"
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const client = new index_js_1.Client({
|
|
20
|
+
name: "test-agent",
|
|
21
|
+
version: "1.0.0"
|
|
22
|
+
}, {
|
|
23
|
+
capabilities: {}
|
|
24
|
+
});
|
|
25
|
+
await client.connect(transport);
|
|
26
|
+
// Define a YAMO Genesis Block
|
|
27
|
+
const yamoContent = `
|
|
28
|
+
block: 00001;
|
|
29
|
+
previous_block: 0;
|
|
30
|
+
agent: Genesis_Agent;
|
|
31
|
+
intent: initialize_yamo_chain;
|
|
32
|
+
output: yamo_chain_started;
|
|
33
|
+
meta: hypothesis;Blockchain anchoring works;
|
|
34
|
+
meta: confidence;1.0;
|
|
35
|
+
signature: genesis_sig;
|
|
36
|
+
`.trim();
|
|
37
|
+
const contentHash = crypto_1.default.createHash('sha256').update(yamoContent).digest('hex');
|
|
38
|
+
console.log("Submitting YAMO Genesis Block...");
|
|
39
|
+
const submitResult = await client.callTool({
|
|
40
|
+
name: "yamo_submit_block",
|
|
41
|
+
arguments: {
|
|
42
|
+
blockId: "00001",
|
|
43
|
+
previousBlock: "0",
|
|
44
|
+
contentHash: contentHash,
|
|
45
|
+
consensusType: "genesis",
|
|
46
|
+
ledger: "local_hardhat"
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
console.log("Submit Result:", JSON.stringify(submitResult, null, 2));
|
|
50
|
+
console.log("\nVerifying Block...");
|
|
51
|
+
const verifyResult = await client.callTool({
|
|
52
|
+
name: "yamo_verify_block",
|
|
53
|
+
arguments: {
|
|
54
|
+
blockId: "00001",
|
|
55
|
+
contentHash: contentHash
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
console.log("Verify Result:", JSON.stringify(verifyResult, null, 2));
|
|
59
|
+
process.exit(0);
|
|
60
|
+
}
|
|
61
|
+
runTest().catch(console.error);
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yamo/mcp-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "YAMO Protocol v0.4 - Model Context Protocol server for AI agents",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"prepublishOnly": "npm run build",
|
|
15
|
+
"start": "node dist/index.js",
|
|
16
|
+
"dev": "ts-node src/index.ts"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"yamo",
|
|
20
|
+
"mcp",
|
|
21
|
+
"ai",
|
|
22
|
+
"agent"
|
|
23
|
+
],
|
|
24
|
+
"author": "YAMO Protocol",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/yamo-protocol/yamo-mcp-server.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/yamo-protocol/yamo-mcp-server/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/yamo-protocol/yamo-mcp-server#readme",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/form-data": "^2.2.1",
|
|
36
|
+
"@types/node": "^25.0.3",
|
|
37
|
+
"ts-node": "^10.9.2",
|
|
38
|
+
"typescript": "^5.9.3"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
42
|
+
"@yamo/core": "^1.0.0",
|
|
43
|
+
"axios": "^1.13.2",
|
|
44
|
+
"dotenv": "^17.2.3",
|
|
45
|
+
"form-data": "^4.0.5"
|
|
46
|
+
}
|
|
47
|
+
}
|