@kya-os/create-mcpi-app 1.2.34 → 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 +13 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/helpers/fetch-cloudflare-mcpi-template.d.ts +2 -3
- package/dist/helpers/fetch-cloudflare-mcpi-template.d.ts.map +1 -1
- package/dist/helpers/fetch-cloudflare-mcpi-template.js +191 -188
- package/dist/helpers/fetch-cloudflare-mcpi-template.js.map +1 -1
- package/package.json +3 -3
|
@@ -3,9 +3,8 @@ interface CloudflareMcpiTemplateOptions {
|
|
|
3
3
|
projectName?: string;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
* Scaffold Cloudflare Worker MCP
|
|
7
|
-
*
|
|
8
|
-
* Uses agents/mcp for MCP session management and @kya-os/verifier for proofs
|
|
6
|
+
* Scaffold Cloudflare Worker MCP server
|
|
7
|
+
* Uses McpAgent from agents/mcp for MCP protocol support
|
|
9
8
|
*/
|
|
10
9
|
export declare function fetchCloudflareMcpiTemplate(projectPath: string, options?: CloudflareMcpiTemplateOptions): Promise<void>;
|
|
11
10
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-cloudflare-mcpi-template.d.ts","sourceRoot":"","sources":["../../src/helpers/fetch-cloudflare-mcpi-template.ts"],"names":[],"mappings":"AAIA,UAAU,6BAA6B;IACrC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED
|
|
1
|
+
{"version":3,"file":"fetch-cloudflare-mcpi-template.d.ts","sourceRoot":"","sources":["../../src/helpers/fetch-cloudflare-mcpi-template.ts"],"names":[],"mappings":"AAIA,UAAU,6BAA6B;IACrC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,6BAAkC,GAC1C,OAAO,CAAC,IAAI,CAAC,CA2af"}
|
|
@@ -2,16 +2,18 @@ import fs from "fs-extra";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
/**
|
|
5
|
-
* Scaffold Cloudflare Worker MCP
|
|
6
|
-
*
|
|
7
|
-
* Uses agents/mcp for MCP session management and @kya-os/verifier for proofs
|
|
5
|
+
* Scaffold Cloudflare Worker MCP server
|
|
6
|
+
* Uses McpAgent from agents/mcp for MCP protocol support
|
|
8
7
|
*/
|
|
9
8
|
export async function fetchCloudflareMcpiTemplate(projectPath, options = {}) {
|
|
10
9
|
const { packageManager = "npm", projectName = path.basename(projectPath) } = options;
|
|
11
|
-
// Sanitize project name for class names
|
|
12
|
-
const className = projectName
|
|
10
|
+
// Sanitize project name for class names
|
|
11
|
+
const className = projectName
|
|
12
|
+
.replace(/[^a-zA-Z0-9]/g, "")
|
|
13
|
+
.replace(/^[0-9]/, "_$&");
|
|
14
|
+
const pascalClassName = className.charAt(0).toUpperCase() + className.slice(1);
|
|
13
15
|
try {
|
|
14
|
-
console.log(chalk.blue("📦 Setting up Cloudflare Worker MCP
|
|
16
|
+
console.log(chalk.blue("📦 Setting up Cloudflare Worker MCP server..."));
|
|
15
17
|
// Create package.json
|
|
16
18
|
const packageJson = {
|
|
17
19
|
name: projectName,
|
|
@@ -31,6 +33,10 @@ export async function fetchCloudflareMcpiTemplate(projectPath, options = {}) {
|
|
|
31
33
|
},
|
|
32
34
|
dependencies: {
|
|
33
35
|
"@kya-os/mcp-i-cloudflare": "^1.1.1",
|
|
36
|
+
"@modelcontextprotocol/sdk": "^1.19.1",
|
|
37
|
+
"agents": "^0.2.8",
|
|
38
|
+
"hono": "^4.9.10",
|
|
39
|
+
"zod": "^3.25.76",
|
|
34
40
|
},
|
|
35
41
|
devDependencies: {
|
|
36
42
|
"@cloudflare/workers-types": "^4.20240925.0",
|
|
@@ -44,37 +50,21 @@ export async function fetchCloudflareMcpiTemplate(projectPath, options = {}) {
|
|
|
44
50
|
const srcDir = path.join(projectPath, "src");
|
|
45
51
|
const toolsDir = path.join(srcDir, "tools");
|
|
46
52
|
fs.ensureDirSync(toolsDir);
|
|
47
|
-
// Create greet tool
|
|
48
|
-
const greetToolContent =
|
|
49
|
-
* Simple greet tool for Cloudflare Workers
|
|
50
|
-
* No external dependencies to avoid Node.js issues
|
|
51
|
-
*/
|
|
53
|
+
// Create greet tool
|
|
54
|
+
const greetToolContent = `import { z } from "zod";
|
|
52
55
|
|
|
53
56
|
export const greetTool = {
|
|
54
57
|
name: "greet",
|
|
55
58
|
description: "Greet a user by name",
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
properties: {
|
|
61
|
-
name: {
|
|
62
|
-
type: "string",
|
|
63
|
-
description: "The name of the user to greet"
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
required: ["name"]
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
// Simple handler that works in Workers environment
|
|
70
|
-
handler: async (args: { name?: string }) => {
|
|
71
|
-
const name = args.name || "Guest";
|
|
72
|
-
|
|
59
|
+
inputSchema: z.object({
|
|
60
|
+
name: z.string().describe("The name of the user to greet")
|
|
61
|
+
}),
|
|
62
|
+
handler: async ({ name }: { name: string }) => {
|
|
73
63
|
return {
|
|
74
64
|
content: [
|
|
75
65
|
{
|
|
76
|
-
type: "text",
|
|
77
|
-
text: \`Hello, \${name}! Welcome to your Cloudflare MCP
|
|
66
|
+
type: "text" as const,
|
|
67
|
+
text: \`Hello, \${name}! Welcome to your Cloudflare MCP server.\`
|
|
78
68
|
}
|
|
79
69
|
]
|
|
80
70
|
};
|
|
@@ -82,60 +72,116 @@ export const greetTool = {
|
|
|
82
72
|
};
|
|
83
73
|
`;
|
|
84
74
|
fs.writeFileSync(path.join(toolsDir, "greet.ts"), greetToolContent);
|
|
85
|
-
// Create main index.ts using
|
|
86
|
-
const indexContent = `import {
|
|
75
|
+
// Create main index.ts using McpAgent with MCP-I runtime
|
|
76
|
+
const indexContent = `import { McpAgent } from "agents/mcp";
|
|
77
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
78
|
+
import { createCloudflareRuntime, type CloudflareEnv } from "@kya-os/mcp-i-cloudflare";
|
|
79
|
+
import { Hono } from "hono";
|
|
80
|
+
import { cors } from "hono/cors";
|
|
87
81
|
import { greetTool } from "./tools/greet";
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
MCPI_ENV?: 'development' | 'production';
|
|
95
|
-
// Additional environment variables can be added here
|
|
96
|
-
}
|
|
83
|
+
export class ${pascalClassName}MCP extends McpAgent {
|
|
84
|
+
server = new McpServer({
|
|
85
|
+
name: "${projectName}",
|
|
86
|
+
version: "1.0.0"
|
|
87
|
+
});
|
|
97
88
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
* - /sse - Dedicated SSE endpoint for Claude Desktop
|
|
111
|
-
* - /.well-known/mcp-identity/* - Identity verification
|
|
112
|
-
*/
|
|
113
|
-
export default {
|
|
114
|
-
async fetch(request: Request, env: Env): Promise<Response> {
|
|
115
|
-
// Create MCP-I adapter with tools
|
|
116
|
-
const adapter = createMCPICloudflareAdapter({
|
|
117
|
-
env,
|
|
118
|
-
serverInfo: {
|
|
119
|
-
name: "${projectName}",
|
|
120
|
-
version: "1.0.0"
|
|
121
|
-
},
|
|
122
|
-
tools: [greetTool],
|
|
123
|
-
environment: env.MCPI_ENV as 'development' | 'production' || 'development'
|
|
89
|
+
private mcpiRuntime?: any;
|
|
90
|
+
|
|
91
|
+
constructor(state: DurableObjectState, env: CloudflareEnv) {
|
|
92
|
+
super(state, env);
|
|
93
|
+
|
|
94
|
+
// Initialize MCP-I runtime for cryptographic proofs and identity
|
|
95
|
+
this.mcpiRuntime = createCloudflareRuntime({
|
|
96
|
+
env: env,
|
|
97
|
+
audit: {
|
|
98
|
+
enabled: true,
|
|
99
|
+
logFunction: (record) => console.log('[MCP-I Audit]', record)
|
|
100
|
+
}
|
|
124
101
|
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async init() {
|
|
105
|
+
// Initialize MCP-I runtime (generates/loads identity, sets up nonce cache)
|
|
106
|
+
await this.mcpiRuntime?.initialize();
|
|
107
|
+
|
|
108
|
+
const identity = await this.mcpiRuntime?.getIdentity();
|
|
109
|
+
console.log('[MCP-I] Initialized with DID:', identity?.did);
|
|
110
|
+
|
|
111
|
+
this.server.tool(
|
|
112
|
+
greetTool.name,
|
|
113
|
+
greetTool.description,
|
|
114
|
+
greetTool.inputSchema.shape,
|
|
115
|
+
async (args: any) => {
|
|
116
|
+
// Execute tool handler
|
|
117
|
+
const result = await greetTool.handler(args);
|
|
118
|
+
|
|
119
|
+
// Generate cryptographic proof (optional but recommended for auditability)
|
|
120
|
+
if (this.mcpiRuntime) {
|
|
121
|
+
try {
|
|
122
|
+
const { proof } = await this.mcpiRuntime.processToolCall(
|
|
123
|
+
greetTool.name,
|
|
124
|
+
args,
|
|
125
|
+
async () => result,
|
|
126
|
+
null // Ephemeral session for Cloudflare Workers
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
if (proof) {
|
|
130
|
+
console.log('[MCP-I Proof]', {
|
|
131
|
+
tool: greetTool.name,
|
|
132
|
+
did: proof.did,
|
|
133
|
+
proofId: proof.meta?.proofId,
|
|
134
|
+
signature: proof.signature.substring(0, 20) + '...'
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.error('[MCP-I] Failed to generate proof:', error);
|
|
139
|
+
// Continue even if proof generation fails
|
|
140
|
+
}
|
|
141
|
+
}
|
|
125
142
|
|
|
126
|
-
|
|
127
|
-
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
);
|
|
128
146
|
}
|
|
129
|
-
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const app = new Hono();
|
|
150
|
+
|
|
151
|
+
app.use("/*", cors({
|
|
152
|
+
origin: "*",
|
|
153
|
+
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
154
|
+
allowHeaders: ["Content-Type", "Authorization", "mcp-session-id", "mcp-protocol-version"],
|
|
155
|
+
exposeHeaders: ["mcp-session-id"],
|
|
156
|
+
}));
|
|
157
|
+
|
|
158
|
+
app.get("/health", (c) => c.json({
|
|
159
|
+
status: 'healthy',
|
|
160
|
+
timestamp: new Date().toISOString(),
|
|
161
|
+
transport: { sse: '/sse', streamableHttp: '/mcp' }
|
|
162
|
+
}));
|
|
163
|
+
|
|
164
|
+
app.mount("/sse", ${pascalClassName}MCP.serveSSE("/sse").fetch, { replaceRequest: false });
|
|
165
|
+
app.mount("/mcp", ${pascalClassName}MCP.serve("/mcp").fetch, { replaceRequest: false });
|
|
166
|
+
|
|
167
|
+
export default app;
|
|
130
168
|
`;
|
|
131
169
|
fs.writeFileSync(path.join(srcDir, "index.ts"), indexContent);
|
|
132
|
-
// Create wrangler.toml
|
|
170
|
+
// Create wrangler.toml
|
|
133
171
|
const wranglerContent = `#:schema node_modules/wrangler/config-schema.json
|
|
134
172
|
name = "${projectName}"
|
|
135
173
|
main = "src/index.ts"
|
|
136
174
|
compatibility_date = "2025-06-18"
|
|
137
175
|
compatibility_flags = ["nodejs_compat"]
|
|
138
176
|
|
|
177
|
+
[[durable_objects.bindings]]
|
|
178
|
+
name = "MCP_OBJECT"
|
|
179
|
+
class_name = "${pascalClassName}MCP"
|
|
180
|
+
|
|
181
|
+
[[migrations]]
|
|
182
|
+
tag = "v1"
|
|
183
|
+
new_sqlite_classes = ["${pascalClassName}MCP"]
|
|
184
|
+
|
|
139
185
|
# KV Namespace for nonce cache (REQUIRED for replay attack prevention)
|
|
140
186
|
#
|
|
141
187
|
# RECOMMENDED: Share a single NONCE_CACHE namespace across all MCP-I workers
|
|
@@ -162,35 +208,9 @@ id = "your-nonce-kv-namespace-id" # Replace with actual namespace ID
|
|
|
162
208
|
binding = "PROOF_ARCHIVE" # Binding name must match runtime expectation
|
|
163
209
|
id = "your-proof-kv-namespace-id" # Replace with actual namespace ID
|
|
164
210
|
|
|
165
|
-
# Optional: KV Namespace for identity storage (development)
|
|
166
|
-
# [[kv_namespaces]]
|
|
167
|
-
# binding = "IDENTITY_STORAGE"
|
|
168
|
-
# id = "your-identity-kv-id"
|
|
169
|
-
|
|
170
|
-
# Environment variables (non-sensitive)
|
|
171
211
|
[vars]
|
|
172
|
-
MCPI_ENV = "development"
|
|
173
212
|
XMCP_I_TS_SKEW_SEC = "120"
|
|
174
213
|
XMCP_I_SESSION_TTL = "1800"
|
|
175
|
-
|
|
176
|
-
# MCP-I Identity (set these via wrangler secrets for production)
|
|
177
|
-
# wrangler secret put MCP_IDENTITY_PRIVATE_KEY
|
|
178
|
-
# wrangler secret put MCP_IDENTITY_PUBLIC_KEY
|
|
179
|
-
# wrangler secret put MCP_IDENTITY_DID
|
|
180
|
-
# wrangler secret put MCP_IDENTITY_KEY_ID
|
|
181
|
-
|
|
182
|
-
# Production environment
|
|
183
|
-
[env.production]
|
|
184
|
-
name = "${projectName}-production"
|
|
185
|
-
vars = { XMCP_I_TS_SKEW_SEC = "60" }
|
|
186
|
-
|
|
187
|
-
[[env.production.kv_namespaces]]
|
|
188
|
-
binding = "NONCE_CACHE"
|
|
189
|
-
id = "your-production-nonce-kv-id"
|
|
190
|
-
|
|
191
|
-
[[env.production.kv_namespaces]]
|
|
192
|
-
binding = "PROOF_ARCHIVE"
|
|
193
|
-
id = "your-production-proof-kv-id"
|
|
194
214
|
`;
|
|
195
215
|
fs.writeFileSync(path.join(projectPath, "wrangler.toml"), wranglerContent);
|
|
196
216
|
// Create tsconfig.json
|
|
@@ -224,7 +244,16 @@ dist/
|
|
|
224
244
|
// Create README.md
|
|
225
245
|
const readmeContent = `# ${projectName}
|
|
226
246
|
|
|
227
|
-
MCP
|
|
247
|
+
MCP server running on Cloudflare Workers with MCP-I identity features, cryptographic proofs, and full SSE/HTTP streaming support.
|
|
248
|
+
|
|
249
|
+
## Features
|
|
250
|
+
|
|
251
|
+
- ✅ **MCP Protocol Support**: SSE and HTTP streaming transports
|
|
252
|
+
- ✅ **Cryptographic Identity**: DID-based agent identity with Ed25519 signatures
|
|
253
|
+
- ✅ **Proof Generation**: Every tool call generates a cryptographic proof
|
|
254
|
+
- ✅ **Audit Logging**: Track all operations with proof IDs and signatures
|
|
255
|
+
- ✅ **Nonce Protection**: Replay attack prevention via KV-backed nonce cache
|
|
256
|
+
- ✅ **Proof Archiving**: Optional KV storage for proof history
|
|
228
257
|
|
|
229
258
|
## Quick Start
|
|
230
259
|
|
|
@@ -242,8 +271,6 @@ ${packageManager} install
|
|
|
242
271
|
${packageManager === "npm" ? "npm run" : packageManager} kv:create-nonce
|
|
243
272
|
\`\`\`
|
|
244
273
|
|
|
245
|
-
This runs: \`wrangler kv namespace create NONCE_CACHE\`
|
|
246
|
-
|
|
247
274
|
Copy the \`id\` from the output and update \`wrangler.toml\`:
|
|
248
275
|
|
|
249
276
|
\`\`\`toml
|
|
@@ -276,39 +303,22 @@ id = "your-proof-kv-id-here" # ← Update this
|
|
|
276
303
|
${packageManager === "npm" ? "npm run" : packageManager} dev
|
|
277
304
|
\`\`\`
|
|
278
305
|
|
|
279
|
-
|
|
280
|
-
- MCP: http://localhost:8787/mcp
|
|
281
|
-
- Verify: http://localhost:8787/verify
|
|
282
|
-
- Health: http://localhost:8787/health
|
|
283
|
-
|
|
284
|
-
### 4. Deploy to Cloudflare
|
|
306
|
+
### 4. Deploy
|
|
285
307
|
|
|
286
308
|
\`\`\`bash
|
|
287
|
-
# Login to Cloudflare (first time only)
|
|
288
|
-
npx wrangler login
|
|
289
|
-
|
|
290
|
-
# Deploy to development
|
|
291
309
|
${packageManager === "npm" ? "npm run" : packageManager} deploy
|
|
292
|
-
|
|
293
|
-
# Deploy to production
|
|
294
|
-
${packageManager === "npm" ? "npm run" : packageManager} deploy --env production
|
|
295
310
|
\`\`\`
|
|
296
311
|
|
|
297
312
|
## Connect with Claude Desktop
|
|
298
313
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
Add to your \`claude_desktop_config.json\`:
|
|
314
|
+
Add to \`~/Library/Application Support/Claude/claude_desktop_config.json\`:
|
|
302
315
|
|
|
303
316
|
\`\`\`json
|
|
304
317
|
{
|
|
305
318
|
"mcpServers": {
|
|
306
319
|
"${projectName}": {
|
|
307
320
|
"command": "npx",
|
|
308
|
-
"args": [
|
|
309
|
-
"mcp-remote",
|
|
310
|
-
"https://your-worker.workers.dev/sse"
|
|
311
|
-
]
|
|
321
|
+
"args": ["mcp-remote", "https://your-worker.workers.dev/sse"]
|
|
312
322
|
}
|
|
313
323
|
}
|
|
314
324
|
}
|
|
@@ -316,106 +326,99 @@ Add to your \`claude_desktop_config.json\`:
|
|
|
316
326
|
|
|
317
327
|
**Note:** Use the \`/sse\` endpoint for Claude Desktop compatibility.
|
|
318
328
|
|
|
329
|
+
Restart Claude Desktop and test: "Use the greet tool to say hello to Alice"
|
|
330
|
+
|
|
319
331
|
## Adding Tools
|
|
320
332
|
|
|
321
|
-
Create
|
|
333
|
+
Create tools in \`src/tools/\`:
|
|
322
334
|
|
|
323
335
|
\`\`\`typescript
|
|
324
|
-
// src/tools/example.ts
|
|
325
336
|
import { z } from "zod";
|
|
326
|
-
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/types.js";
|
|
327
337
|
|
|
328
|
-
export const
|
|
329
|
-
name: "
|
|
330
|
-
description: "
|
|
338
|
+
export const myTool = {
|
|
339
|
+
name: "my_tool",
|
|
340
|
+
description: "Tool description",
|
|
331
341
|
inputSchema: z.object({
|
|
332
|
-
input: z.string().describe("Input parameter")
|
|
342
|
+
input: z.string().describe("Input parameter")
|
|
333
343
|
}),
|
|
334
|
-
handler: async (
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
content: [
|
|
338
|
-
{
|
|
339
|
-
type: "text" as const,
|
|
340
|
-
text: \`Result: \${input}\`
|
|
341
|
-
}
|
|
342
|
-
],
|
|
343
|
-
};
|
|
344
|
-
},
|
|
344
|
+
handler: async ({ input }: { input: string }) => ({
|
|
345
|
+
content: [{ type: "text" as const, text: \`Result: \${input}\` }]
|
|
346
|
+
})
|
|
345
347
|
};
|
|
346
348
|
\`\`\`
|
|
347
349
|
|
|
348
|
-
Register in \`src/index.ts
|
|
350
|
+
Register in \`src/index.ts\` init method:
|
|
349
351
|
|
|
350
352
|
\`\`\`typescript
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
exampleTool.inputSchema.shape,
|
|
358
|
-
exampleTool.handler
|
|
359
|
-
);
|
|
360
|
-
}
|
|
353
|
+
this.server.tool(
|
|
354
|
+
myTool.name,
|
|
355
|
+
myTool.description,
|
|
356
|
+
myTool.inputSchema.shape,
|
|
357
|
+
myTool.handler
|
|
358
|
+
);
|
|
361
359
|
\`\`\`
|
|
362
360
|
|
|
363
|
-
##
|
|
361
|
+
## Endpoints
|
|
364
362
|
|
|
365
|
-
|
|
366
|
-
|
|
363
|
+
- \`/health\` - Health check
|
|
364
|
+
- \`/sse\` - SSE transport for MCP
|
|
365
|
+
- \`/mcp\` - Streamable HTTP transport for MCP
|
|
367
366
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
"status": "healthy",
|
|
372
|
-
"timestamp": "2024-10-10T12:00:00.000Z"
|
|
373
|
-
}
|
|
374
|
-
\`\`\`
|
|
367
|
+
## Viewing Cryptographic Proofs
|
|
368
|
+
|
|
369
|
+
Every tool call generates a cryptographic proof that's logged to the console:
|
|
375
370
|
|
|
376
|
-
|
|
377
|
-
|
|
371
|
+
\`\`\`bash
|
|
372
|
+
${packageManager === "npm" ? "npm run" : packageManager} dev
|
|
373
|
+
\`\`\`
|
|
378
374
|
|
|
379
|
-
|
|
380
|
-
Verify MCP-I cryptographic proofs.
|
|
375
|
+
When you call a tool, you'll see logs like:
|
|
381
376
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
{
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
"signature": "...",
|
|
390
|
-
"publicKey": "..."
|
|
391
|
-
}
|
|
377
|
+
\`\`\`
|
|
378
|
+
[MCP-I] Initialized with DID: did:web:localhost:agents:key-abc123
|
|
379
|
+
[MCP-I Proof] {
|
|
380
|
+
tool: 'greet',
|
|
381
|
+
did: 'did:web:localhost:agents:key-abc123',
|
|
382
|
+
proofId: 'proof_1234567890_abcd',
|
|
383
|
+
signature: 'mNYP8x2k9FqV3...'
|
|
392
384
|
}
|
|
393
385
|
\`\`\`
|
|
394
386
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
387
|
+
### Proof Archives (Optional)
|
|
388
|
+
|
|
389
|
+
If you configured the \`PROOF_ARCHIVE\` KV namespace, proofs are also stored for querying:
|
|
390
|
+
|
|
391
|
+
\`\`\`bash
|
|
392
|
+
# List all proofs
|
|
393
|
+
wrangler kv:key list --namespace-id=your-proof-kv-id
|
|
394
|
+
|
|
395
|
+
# View a specific proof
|
|
396
|
+
wrangler kv:key get "proof_1234567890_abcd" --namespace-id=your-proof-kv-id
|
|
406
397
|
\`\`\`
|
|
407
398
|
|
|
408
|
-
##
|
|
399
|
+
## Identity Management
|
|
400
|
+
|
|
401
|
+
Your agent's cryptographic identity is stored in Durable Objects state. To view your agent's DID:
|
|
402
|
+
|
|
403
|
+
1. Check the logs during \`init()\` - it prints the DID
|
|
404
|
+
2. Or query the runtime: \`await mcpiRuntime.getIdentity()\`
|
|
405
|
+
|
|
406
|
+
The identity includes:
|
|
407
|
+
- \`did\`: Decentralized identifier (e.g., \`did:web:your-worker.workers.dev:agents:key-xyz\`)
|
|
408
|
+
- \`publicKey\`: Ed25519 public key for signature verification
|
|
409
|
+
- \`privateKey\`: Ed25519 private key (secured in Durable Object state)
|
|
410
|
+
|
|
411
|
+
## References
|
|
409
412
|
|
|
413
|
+
- [Cloudflare Agents MCP](https://developers.cloudflare.com/agents/model-context-protocol/)
|
|
414
|
+
- [MCP Specification](https://spec.modelcontextprotocol.io/)
|
|
410
415
|
- [MCP-I Documentation](https://github.com/kya-os/xmcp-i)
|
|
411
|
-
- [Cloudflare Workers](https://developers.cloudflare.com/workers/)
|
|
412
|
-
- [agents/mcp](https://www.npmjs.com/package/agents)
|
|
413
416
|
`;
|
|
414
417
|
fs.writeFileSync(path.join(projectPath, "README.md"), readmeContent);
|
|
415
|
-
console.log(chalk.green("✅ Cloudflare Worker MCP
|
|
418
|
+
console.log(chalk.green("✅ Cloudflare Worker MCP server created"));
|
|
416
419
|
}
|
|
417
420
|
catch (error) {
|
|
418
|
-
console.error(chalk.red("Failed to set up Cloudflare Worker MCP
|
|
421
|
+
console.error(chalk.red("Failed to set up Cloudflare Worker MCP server:"), error);
|
|
419
422
|
throw error;
|
|
420
423
|
}
|
|
421
424
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-cloudflare-mcpi-template.js","sourceRoot":"","sources":["../../src/helpers/fetch-cloudflare-mcpi-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B
|
|
1
|
+
{"version":3,"file":"fetch-cloudflare-mcpi-template.js","sourceRoot":"","sources":["../../src/helpers/fetch-cloudflare-mcpi-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC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;;;;;;;;;;;;;;;;;;;;;EAqDhB,cAAc,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CtD,CAAC;QACE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,aAAa,CAAC,CAAC;QAErE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC,CAAC;IACrE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,gDAAgD,CAAC,EAAE,KAAK,CAAC,CAAC;QAClF,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/create-mcpi-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Bootstrap MCP applications with identity features",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"prepublishOnly": "npm run build && node scripts/validate-no-workspace.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@kya-os/cli": "^1.
|
|
19
|
+
"@kya-os/cli": "^1.3.0",
|
|
20
20
|
"@kya-os/cli-effects": "^1.0.9",
|
|
21
|
-
"@kya-os/contracts": "^1.
|
|
21
|
+
"@kya-os/contracts": "^1.3.0",
|
|
22
22
|
"@noble/ed25519": "^2.1.0",
|
|
23
23
|
"axios": "^1.12.0",
|
|
24
24
|
"chalk": "^5.3.0",
|