@kya-os/create-mcpi-app 1.2.16 ā 1.2.18
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/dist/.tsbuildinfo +1 -1
- package/dist/helpers/create.d.ts +1 -0
- package/dist/helpers/create.d.ts.map +1 -1
- package/dist/helpers/create.js +32 -18
- package/dist/helpers/create.js.map +1 -1
- package/dist/helpers/fetch-cloudflare-template.d.ts +11 -0
- package/dist/helpers/fetch-cloudflare-template.d.ts.map +1 -0
- package/dist/helpers/fetch-cloudflare-template.js +341 -0
- package/dist/helpers/fetch-cloudflare-template.js.map +1 -0
- package/dist/index.js +79 -44
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/helpers/create.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/helpers/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/helpers/create.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AA4CrD,UAAU,oBAAoB;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AASD;;GAEG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAiI3B"}
|
package/dist/helpers/create.js
CHANGED
|
@@ -2,6 +2,7 @@ import path from "path";
|
|
|
2
2
|
import fs from "fs-extra";
|
|
3
3
|
import { fileURLToPath } from "url";
|
|
4
4
|
import { fetchMCPITemplate } from "./fetch-mcpi-template.js";
|
|
5
|
+
import { fetchCloudflareTemplate } from "./fetch-cloudflare-template.js";
|
|
5
6
|
import { renameFiles } from "./rename.js";
|
|
6
7
|
import { install } from "./install.js";
|
|
7
8
|
import { validateProjectStructure, ensureLockfile, } from "./validate-project-structure.js";
|
|
@@ -50,18 +51,27 @@ function createProjectDirectories(projectPath) {
|
|
|
50
51
|
* Create a new MCP-I project with identity features
|
|
51
52
|
*/
|
|
52
53
|
export async function createProject(options) {
|
|
53
|
-
const { projectPath, projectName, packageManager, transports, packageVersion, useLocalXmcp, mcpiVersion, deployToVercel, skipInstall, agentName = projectName, agentDescription = "MCP-I server with identity features", agentRepository = "", skipIdentity = false, skipAnimation = false, fastAnimation = false, } = options;
|
|
54
|
+
const { projectPath, projectName, packageManager, transports, packageVersion, useLocalXmcp, mcpiVersion, deployToVercel, skipInstall, agentName = projectName, agentDescription = "MCP-I server with identity features", agentRepository = "", skipIdentity = false, skipAnimation = false, fastAnimation = false, template = "default", } = options;
|
|
54
55
|
const warnings = [];
|
|
55
56
|
let resolvedMcpiVersion = mcpiVersion;
|
|
56
57
|
try {
|
|
57
58
|
// Ensure the project directory exists
|
|
58
59
|
fs.ensureDirSync(projectPath);
|
|
59
|
-
// Scaffold
|
|
60
|
-
console.log(chalk.blue("\nš Scaffolding
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
// Scaffold project based on template
|
|
61
|
+
console.log(chalk.blue("\nš Scaffolding project..."));
|
|
62
|
+
if (template === "cloudflare") {
|
|
63
|
+
// Cloudflare Worker verifier template
|
|
64
|
+
await fetchCloudflareTemplate(projectPath, {
|
|
65
|
+
packageManager,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// Default MCP-I server template
|
|
70
|
+
await fetchMCPITemplate(projectPath, {
|
|
71
|
+
mcpiVersion,
|
|
72
|
+
packageManager,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
65
75
|
// Capture the resolved version for the result
|
|
66
76
|
const packageJsonPath = path.join(projectPath, "package.json");
|
|
67
77
|
if (fs.existsSync(packageJsonPath)) {
|
|
@@ -92,25 +102,29 @@ export async function createProject(options) {
|
|
|
92
102
|
spaces: 2,
|
|
93
103
|
});
|
|
94
104
|
}
|
|
95
|
-
// Create necessary project directories
|
|
96
|
-
|
|
105
|
+
// Create necessary project directories (skip for cloudflare template)
|
|
106
|
+
if (template !== "cloudflare") {
|
|
107
|
+
createProjectDirectories(projectPath);
|
|
108
|
+
}
|
|
97
109
|
// Install project dependencies
|
|
98
110
|
if (!skipInstall) {
|
|
99
111
|
install(projectPath, packageManager, packageVersion);
|
|
100
112
|
// Ensure lockfile is properly created
|
|
101
113
|
ensureLockfile(projectPath, packageManager);
|
|
102
114
|
}
|
|
103
|
-
// Validate project structure meets requirements
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
// Validate project structure meets requirements (skip for cloudflare)
|
|
116
|
+
if (template !== "cloudflare") {
|
|
117
|
+
const validation = validateProjectStructure(projectPath, !skipIdentity);
|
|
118
|
+
if (!validation.valid) {
|
|
119
|
+
console.warn(chalk.yellow("ā ļø Project structure validation issues:"));
|
|
120
|
+
for (const issue of validation.issues) {
|
|
121
|
+
console.warn(chalk.yellow(` - ${issue}`));
|
|
122
|
+
warnings.push(...validation.issues);
|
|
123
|
+
}
|
|
110
124
|
}
|
|
111
125
|
}
|
|
112
|
-
// Identity setup is now handled by the CLI after scaffolding
|
|
113
|
-
if (!skipIdentity) {
|
|
126
|
+
// Identity setup is now handled by the CLI after scaffolding (not for cloudflare)
|
|
127
|
+
if (!skipIdentity && template !== "cloudflare") {
|
|
114
128
|
console.log(chalk.blue("\nš Identity setup will be handled by the CLI"));
|
|
115
129
|
console.log(chalk.gray(" Run 'mcpi init' after scaffolding to set up identity"));
|
|
116
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/helpers/create.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,wBAAwB,EACxB,cAAc,GACf,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,iCAAiC;AACjC,SAAS,gBAAgB,CAAC,GAAW,EAAE,gBAAwB;IAC7D,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC;QAEtC,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAA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EAAE,KAAK;YACd,WAAW;YACX,WAAW,EAAE,mBAAmB,IAAI,SAAS;YAC7C,eAAe,EAAE,CAAC,YAAY;YAC9B,QAAQ,EAAE;gBACR,4BAA4B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aACrF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface CloudflareTemplateOptions {
|
|
2
|
+
verifierVersion?: string;
|
|
3
|
+
packageManager?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Scaffold Cloudflare Worker verifier project
|
|
7
|
+
* This creates a standalone Worker verifier with KV nonce caching
|
|
8
|
+
*/
|
|
9
|
+
export declare function fetchCloudflareTemplate(projectPath: string, options?: CloudflareTemplateOptions): Promise<void>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=fetch-cloudflare-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-cloudflare-template.d.ts","sourceRoot":"","sources":["../../src/helpers/fetch-cloudflare-template.ts"],"names":[],"mappings":"AAQA,UAAU,yBAAyB;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,IAAI,CAAC,CAoVf"}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
/**
|
|
8
|
+
* Scaffold Cloudflare Worker verifier project
|
|
9
|
+
* This creates a standalone Worker verifier with KV nonce caching
|
|
10
|
+
*/
|
|
11
|
+
export async function fetchCloudflareTemplate(projectPath, options = {}) {
|
|
12
|
+
const { verifierVersion = "^1.3.0", packageManager = "npm" } = options;
|
|
13
|
+
try {
|
|
14
|
+
console.log(chalk.blue(`š¦ Setting up Cloudflare Worker verifier with @kya-os/verifier@${verifierVersion}...`));
|
|
15
|
+
// Create package.json for Cloudflare Worker
|
|
16
|
+
const packageJson = {
|
|
17
|
+
name: path.basename(projectPath),
|
|
18
|
+
version: "1.0.0",
|
|
19
|
+
type: "module",
|
|
20
|
+
private: true,
|
|
21
|
+
scripts: {
|
|
22
|
+
dev: "wrangler dev",
|
|
23
|
+
deploy: "wrangler deploy",
|
|
24
|
+
"deploy:production": "wrangler deploy --env production",
|
|
25
|
+
"kv:create": "wrangler kv:namespace create NONCE_CACHE",
|
|
26
|
+
"kv:create:preview": "wrangler kv:namespace create NONCE_CACHE --preview",
|
|
27
|
+
tail: "wrangler tail",
|
|
28
|
+
test: "vitest",
|
|
29
|
+
},
|
|
30
|
+
dependencies: {
|
|
31
|
+
"@kya-os/verifier": verifierVersion,
|
|
32
|
+
},
|
|
33
|
+
devDependencies: {
|
|
34
|
+
"@cloudflare/workers-types": "^4.20240925.0",
|
|
35
|
+
"@cloudflare/vitest-pool-workers": "^0.5.0",
|
|
36
|
+
typescript: "^5.6.2",
|
|
37
|
+
vitest: "^2.1.1",
|
|
38
|
+
wrangler: "^3.78.12",
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
// Write package.json
|
|
42
|
+
fs.ensureDirSync(projectPath);
|
|
43
|
+
fs.writeJsonSync(path.join(projectPath, "package.json"), packageJson, { spaces: 2 });
|
|
44
|
+
// Create src directory
|
|
45
|
+
const srcDir = path.join(projectPath, "src");
|
|
46
|
+
fs.ensureDirSync(srcDir);
|
|
47
|
+
// Create Worker implementation
|
|
48
|
+
const workerContent = `import {
|
|
49
|
+
verifyWorker,
|
|
50
|
+
applyVerificationToResponse,
|
|
51
|
+
createConfigFromEnv,
|
|
52
|
+
type WorkerEnv,
|
|
53
|
+
} from "@kya-os/verifier/worker";
|
|
54
|
+
|
|
55
|
+
export default {
|
|
56
|
+
async fetch(request: Request, env: WorkerEnv): Promise<Response> {
|
|
57
|
+
const url = new URL(request.url);
|
|
58
|
+
|
|
59
|
+
// Health check endpoint
|
|
60
|
+
if (url.pathname === "/health") {
|
|
61
|
+
return new Response(
|
|
62
|
+
JSON.stringify({
|
|
63
|
+
status: "healthy",
|
|
64
|
+
timestamp: new Date().toISOString(),
|
|
65
|
+
}),
|
|
66
|
+
{
|
|
67
|
+
headers: { "Content-Type": "application/json" },
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Verification endpoint
|
|
73
|
+
if (url.pathname === "/verify") {
|
|
74
|
+
// Create config from environment variables
|
|
75
|
+
const config = createConfigFromEnv(env, {
|
|
76
|
+
allowMockData: false,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Verify the proof
|
|
80
|
+
const result = await verifyWorker(request, config);
|
|
81
|
+
|
|
82
|
+
// If verification failed, return error response
|
|
83
|
+
if (!result.success) {
|
|
84
|
+
return applyVerificationToResponse(result);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Success - extract agent context
|
|
88
|
+
const agent = result.agentContext;
|
|
89
|
+
|
|
90
|
+
// Check required scopes (example)
|
|
91
|
+
const requiredScopes = ["cart:add", "checkout"];
|
|
92
|
+
const hasRequiredScope = requiredScopes.some((scope) =>
|
|
93
|
+
agent?.scopes?.includes(scope)
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
if (!hasRequiredScope) {
|
|
97
|
+
return new Response(
|
|
98
|
+
JSON.stringify({
|
|
99
|
+
verified: false,
|
|
100
|
+
error: "Insufficient permissions",
|
|
101
|
+
requiredScopes,
|
|
102
|
+
providedScopes: agent?.scopes || [],
|
|
103
|
+
}),
|
|
104
|
+
{
|
|
105
|
+
status: 403,
|
|
106
|
+
headers: { "Content-Type": "application/json" },
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Success response with agent context
|
|
112
|
+
return new Response(
|
|
113
|
+
JSON.stringify({
|
|
114
|
+
verified: true,
|
|
115
|
+
agent: {
|
|
116
|
+
did: agent?.did,
|
|
117
|
+
keyId: agent?.keyId,
|
|
118
|
+
scopes: agent?.scopes,
|
|
119
|
+
session: agent?.session,
|
|
120
|
+
},
|
|
121
|
+
timestamp: new Date().toISOString(),
|
|
122
|
+
}),
|
|
123
|
+
{
|
|
124
|
+
headers: { "Content-Type": "application/json" },
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return new Response("Not Found", { status: 404 });
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
`;
|
|
133
|
+
fs.writeFileSync(path.join(srcDir, "index.ts"), workerContent);
|
|
134
|
+
// Create wrangler.toml
|
|
135
|
+
const wranglerContent = `#:schema node_modules/wrangler/config-schema.json
|
|
136
|
+
name = "${path.basename(projectPath)}"
|
|
137
|
+
main = "src/index.ts"
|
|
138
|
+
compatibility_date = "2024-09-25"
|
|
139
|
+
node_compat = true
|
|
140
|
+
|
|
141
|
+
# KV Namespace for nonce cache
|
|
142
|
+
# Run: wrangler kv:namespace create NONCE_CACHE
|
|
143
|
+
# Then replace the id below with the output
|
|
144
|
+
[[kv_namespaces]]
|
|
145
|
+
binding = "NONCE_CACHE"
|
|
146
|
+
id = "YOUR_KV_NAMESPACE_ID"
|
|
147
|
+
|
|
148
|
+
# Environment variables (non-sensitive)
|
|
149
|
+
[vars]
|
|
150
|
+
KYA_API_URL = "https://knowthat.ai"
|
|
151
|
+
XMCP_I_TS_SKEW_SEC = "120"
|
|
152
|
+
XMCP_I_SESSION_TTL = "1800"
|
|
153
|
+
|
|
154
|
+
# Production environment
|
|
155
|
+
[env.production]
|
|
156
|
+
name = "${path.basename(projectPath)}-production"
|
|
157
|
+
vars = { KYA_API_URL = "https://knowthat.ai", XMCP_I_TS_SKEW_SEC = "60" }
|
|
158
|
+
|
|
159
|
+
[[env.production.kv_namespaces]]
|
|
160
|
+
binding = "NONCE_CACHE"
|
|
161
|
+
id = "YOUR_PRODUCTION_KV_NAMESPACE_ID"
|
|
162
|
+
`;
|
|
163
|
+
fs.writeFileSync(path.join(projectPath, "wrangler.toml"), wranglerContent);
|
|
164
|
+
// Create tsconfig.json
|
|
165
|
+
const tsconfigContent = {
|
|
166
|
+
compilerOptions: {
|
|
167
|
+
target: "ES2022",
|
|
168
|
+
module: "ES2022",
|
|
169
|
+
lib: ["ES2022"],
|
|
170
|
+
types: ["@cloudflare/workers-types"],
|
|
171
|
+
moduleResolution: "bundler",
|
|
172
|
+
resolveJsonModule: true,
|
|
173
|
+
allowSyntheticDefaultImports: true,
|
|
174
|
+
esModuleInterop: true,
|
|
175
|
+
strict: true,
|
|
176
|
+
skipLibCheck: true,
|
|
177
|
+
forceConsistentCasingInFileNames: true,
|
|
178
|
+
},
|
|
179
|
+
include: ["src/**/*"],
|
|
180
|
+
};
|
|
181
|
+
fs.writeJsonSync(path.join(projectPath, "tsconfig.json"), tsconfigContent, { spaces: 2 });
|
|
182
|
+
// Create .gitignore
|
|
183
|
+
const gitignoreContent = `node_modules/
|
|
184
|
+
dist/
|
|
185
|
+
.wrangler/
|
|
186
|
+
.dev.vars
|
|
187
|
+
.env
|
|
188
|
+
.env.local
|
|
189
|
+
*.log
|
|
190
|
+
`;
|
|
191
|
+
fs.writeFileSync(path.join(projectPath, ".gitignore"), gitignoreContent);
|
|
192
|
+
// Create README.md
|
|
193
|
+
const readmeContent = `# ${path.basename(projectPath)}
|
|
194
|
+
|
|
195
|
+
MCP-I proof verifier deployed on Cloudflare Workers with KV nonce caching.
|
|
196
|
+
|
|
197
|
+
## Quick Start
|
|
198
|
+
|
|
199
|
+
### 1. Install Dependencies
|
|
200
|
+
|
|
201
|
+
\`\`\`bash
|
|
202
|
+
${packageManager} install
|
|
203
|
+
\`\`\`
|
|
204
|
+
|
|
205
|
+
### 2. Create KV Namespace
|
|
206
|
+
|
|
207
|
+
\`\`\`bash
|
|
208
|
+
${packageManager === "npm" ? "npm run" : packageManager} kv:create
|
|
209
|
+
\`\`\`
|
|
210
|
+
|
|
211
|
+
Copy the \`id\` from the output and update \`wrangler.toml\`:
|
|
212
|
+
|
|
213
|
+
\`\`\`toml
|
|
214
|
+
[[kv_namespaces]]
|
|
215
|
+
binding = "NONCE_CACHE"
|
|
216
|
+
id = "your-kv-namespace-id-here" # ā Update this
|
|
217
|
+
\`\`\`
|
|
218
|
+
|
|
219
|
+
### 3. Test Locally
|
|
220
|
+
|
|
221
|
+
\`\`\`bash
|
|
222
|
+
${packageManager === "npm" ? "npm run" : packageManager} dev
|
|
223
|
+
\`\`\`
|
|
224
|
+
|
|
225
|
+
Visit http://localhost:8787/health to verify it's running.
|
|
226
|
+
|
|
227
|
+
### 4. Deploy to Cloudflare
|
|
228
|
+
|
|
229
|
+
\`\`\`bash
|
|
230
|
+
# Login to Cloudflare (first time only)
|
|
231
|
+
npx wrangler login
|
|
232
|
+
|
|
233
|
+
# Deploy to development
|
|
234
|
+
${packageManager === "npm" ? "npm run" : packageManager} deploy
|
|
235
|
+
|
|
236
|
+
# Deploy to production
|
|
237
|
+
${packageManager === "npm" ? "npm run" : packageManager} deploy:production
|
|
238
|
+
\`\`\`
|
|
239
|
+
|
|
240
|
+
## API Endpoints
|
|
241
|
+
|
|
242
|
+
### \`GET /health\`
|
|
243
|
+
Health check endpoint.
|
|
244
|
+
|
|
245
|
+
**Response:**
|
|
246
|
+
\`\`\`json
|
|
247
|
+
{
|
|
248
|
+
"status": "healthy",
|
|
249
|
+
"timestamp": "2024-10-09T12:00:00.000Z"
|
|
250
|
+
}
|
|
251
|
+
\`\`\`
|
|
252
|
+
|
|
253
|
+
### \`POST /verify\`
|
|
254
|
+
Verify MCP-I cryptographic proof.
|
|
255
|
+
|
|
256
|
+
**Request:**
|
|
257
|
+
\`\`\`json
|
|
258
|
+
{
|
|
259
|
+
"proof": {
|
|
260
|
+
"agentDid": "did:web:example.com",
|
|
261
|
+
"timestamp": 1234567890,
|
|
262
|
+
"nonce": "abc123",
|
|
263
|
+
"signature": "...",
|
|
264
|
+
"publicKey": "..."
|
|
265
|
+
},
|
|
266
|
+
"requiredScopes": ["cart:add"]
|
|
267
|
+
}
|
|
268
|
+
\`\`\`
|
|
269
|
+
|
|
270
|
+
**Response (Success):**
|
|
271
|
+
\`\`\`json
|
|
272
|
+
{
|
|
273
|
+
"verified": true,
|
|
274
|
+
"agentDid": "did:web:example.com",
|
|
275
|
+
"timestamp": "2024-10-09T12:00:00.000Z"
|
|
276
|
+
}
|
|
277
|
+
\`\`\`
|
|
278
|
+
|
|
279
|
+
**Response (Failed):**
|
|
280
|
+
\`\`\`json
|
|
281
|
+
{
|
|
282
|
+
"verified": false,
|
|
283
|
+
"error": "Invalid signature"
|
|
284
|
+
}
|
|
285
|
+
\`\`\`
|
|
286
|
+
|
|
287
|
+
## Configuration
|
|
288
|
+
|
|
289
|
+
### Environment Variables (wrangler.toml)
|
|
290
|
+
|
|
291
|
+
- \`KYA_API_URL\` - KYA API endpoint (default: https://knowthat.ai)
|
|
292
|
+
- \`XMCP_I_TS_SKEW_SEC\` - Clock skew tolerance in seconds (default: 120)
|
|
293
|
+
- \`XMCP_I_SESSION_TTL\` - Session timeout in seconds (default: 1800)
|
|
294
|
+
|
|
295
|
+
### KV Namespace
|
|
296
|
+
|
|
297
|
+
The Worker uses Cloudflare KV for distributed nonce caching to prevent replay attacks.
|
|
298
|
+
|
|
299
|
+
Create separate namespaces for development and production:
|
|
300
|
+
|
|
301
|
+
\`\`\`bash
|
|
302
|
+
# Development
|
|
303
|
+
${packageManager === "npm" ? "npm run" : packageManager} kv:create
|
|
304
|
+
|
|
305
|
+
# Production (after deploying once)
|
|
306
|
+
wrangler kv:namespace create NONCE_CACHE --env production
|
|
307
|
+
\`\`\`
|
|
308
|
+
|
|
309
|
+
## Testing
|
|
310
|
+
|
|
311
|
+
Send a test request:
|
|
312
|
+
|
|
313
|
+
\`\`\`bash
|
|
314
|
+
curl -X POST https://your-worker.workers.dev/verify \\
|
|
315
|
+
-H "Content-Type: application/json" \\
|
|
316
|
+
-d '{
|
|
317
|
+
"proof": {
|
|
318
|
+
"agentDid": "did:web:example.com",
|
|
319
|
+
"timestamp": 1234567890,
|
|
320
|
+
"nonce": "test123",
|
|
321
|
+
"signature": "...",
|
|
322
|
+
"publicKey": "..."
|
|
323
|
+
}
|
|
324
|
+
}'
|
|
325
|
+
\`\`\`
|
|
326
|
+
|
|
327
|
+
## Learn More
|
|
328
|
+
|
|
329
|
+
- [MCP-I Documentation](https://github.com/kya-os/xmcp-i)
|
|
330
|
+
- [Cloudflare Workers Docs](https://developers.cloudflare.com/workers/)
|
|
331
|
+
- [Cloudflare KV Docs](https://developers.cloudflare.com/kv/)
|
|
332
|
+
`;
|
|
333
|
+
fs.writeFileSync(path.join(projectPath, "README.md"), readmeContent);
|
|
334
|
+
console.log(chalk.green("ā
Cloudflare Worker verifier structure created"));
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
console.error(chalk.red("Failed to set up Cloudflare Worker verifier:"), error);
|
|
338
|
+
throw error;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
//# sourceMappingURL=fetch-cloudflare-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-cloudflare-template.js","sourceRoot":"","sources":["../../src/helpers/fetch-cloudflare-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,I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|
36
36
|
.option("--no-animation", "Skip the black hole animation", false)
|
|
37
37
|
.option("--fast", "Use shorter animation duration", false)
|
|
38
|
+
.option("--template <name>", "Use a specific template (e.g., cloudflare, default)")
|
|
38
39
|
.action(async (projectDir, options) => {
|
|
39
40
|
console.log(chalk.bold(`\ncreate-mcpi-app@${packageJson.version}`));
|
|
40
41
|
// Show KYA-OS banner
|
|
@@ -224,6 +225,7 @@ const program = new Command()
|
|
|
224
225
|
skipAnimation: options.noAnimation === false ? true : false, // Handle --no-animation flag
|
|
225
226
|
fastAnimation: options.fast,
|
|
226
227
|
spinner, // Pass spinner to stop it before animation
|
|
228
|
+
template: options.template || "default", // Pass template option
|
|
227
229
|
});
|
|
228
230
|
if (!result.success) {
|
|
229
231
|
spinner.fail(chalk.red("Failed to create the project."));
|
|
@@ -245,67 +247,100 @@ const program = new Command()
|
|
|
245
247
|
}
|
|
246
248
|
console.log();
|
|
247
249
|
console.log("Next Steps:");
|
|
248
|
-
// Show
|
|
249
|
-
if (
|
|
250
|
-
|
|
251
|
-
console.log("
|
|
250
|
+
// Show different instructions based on template
|
|
251
|
+
if (options.template === "cloudflare") {
|
|
252
|
+
// Cloudflare Worker verifier instructions
|
|
253
|
+
console.log("1. Install dependencies:");
|
|
252
254
|
if (resolvedProjectPath !== process.cwd()) {
|
|
253
255
|
console.log(` cd ${chalk.cyan(projectDir)}`);
|
|
254
256
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
+
if (skipInstall) {
|
|
258
|
+
if (packageManager === "yarn") {
|
|
259
|
+
console.log(` ${chalk.cyan("yarn install")}`);
|
|
260
|
+
}
|
|
261
|
+
else if (packageManager === "pnpm") {
|
|
262
|
+
console.log(` ${chalk.cyan("pnpm install")}`);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
console.log(` ${chalk.cyan("npm install")}`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
257
268
|
console.log();
|
|
269
|
+
console.log("2. Create KV namespace:");
|
|
270
|
+
console.log(` ${chalk.cyan(`${packageManager === "npm" ? "npm run" : packageManager} kv:create`)}`);
|
|
271
|
+
console.log(chalk.gray(" Copy the 'id' from output and update wrangler.toml"));
|
|
272
|
+
console.log();
|
|
273
|
+
console.log("3. Test locally:");
|
|
274
|
+
console.log(` ${chalk.cyan(`${packageManager === "npm" ? "npm run" : packageManager} dev`)}`);
|
|
275
|
+
console.log();
|
|
276
|
+
console.log("4. Deploy to Cloudflare:");
|
|
277
|
+
console.log(` ${chalk.cyan("npx wrangler login")} ${chalk.gray("(first time only)")}`);
|
|
278
|
+
console.log(` ${chalk.cyan(`${packageManager === "npm" ? "npm run" : packageManager} deploy`)}`);
|
|
258
279
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
280
|
+
else {
|
|
281
|
+
// Default MCP-I server instructions
|
|
282
|
+
// Show agent management with claim URL first
|
|
283
|
+
if (!skipIdentity) {
|
|
284
|
+
console.log("Agent management:");
|
|
285
|
+
console.log(" Follow the Claim URL above to claim your agent");
|
|
286
|
+
if (resolvedProjectPath !== process.cwd()) {
|
|
287
|
+
console.log(` cd ${chalk.cyan(projectDir)}`);
|
|
288
|
+
}
|
|
289
|
+
console.log(` ${chalk.cyan(`${packageManager} run status`)} - Check agent status`);
|
|
290
|
+
console.log(` ${chalk.cyan(`${packageManager} run register`)} - Register with registry`);
|
|
291
|
+
console.log();
|
|
266
292
|
}
|
|
267
|
-
|
|
268
|
-
|
|
293
|
+
console.log("Start agent:");
|
|
294
|
+
if (resolvedProjectPath !== process.cwd()) {
|
|
295
|
+
console.log(` cd ${chalk.cyan(projectDir)}`);
|
|
296
|
+
}
|
|
297
|
+
if (skipInstall) {
|
|
298
|
+
if (packageManager === "yarn") {
|
|
299
|
+
console.log(` ${chalk.cyan("yarn install")}`);
|
|
300
|
+
}
|
|
301
|
+
else if (packageManager === "pnpm") {
|
|
302
|
+
console.log(` ${chalk.cyan("pnpm install")}`);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
console.log(` ${chalk.cyan("npm install")}`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
// Show appropriate command based on transport
|
|
309
|
+
if (transports.includes("stdio")) {
|
|
310
|
+
console.log(` ${chalk.cyan("npx xmcp build")}`);
|
|
269
311
|
}
|
|
270
312
|
else {
|
|
271
|
-
|
|
313
|
+
// HTTP transport - show dev command
|
|
314
|
+
if (packageManager === "yarn") {
|
|
315
|
+
console.log(` ${chalk.cyan("yarn dev")}`);
|
|
316
|
+
}
|
|
317
|
+
else if (packageManager === "pnpm") {
|
|
318
|
+
console.log(` ${chalk.cyan("pnpm dev")}`);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
console.log(` ${chalk.cyan("npm run dev")}`);
|
|
322
|
+
}
|
|
272
323
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
// HTTP transport - show dev command
|
|
324
|
+
console.log();
|
|
325
|
+
console.log("Manage identity:");
|
|
326
|
+
if (resolvedProjectPath !== process.cwd()) {
|
|
327
|
+
console.log(` cd ${chalk.cyan(projectDir)}`);
|
|
328
|
+
}
|
|
329
|
+
// Show identity management commands
|
|
280
330
|
if (packageManager === "yarn") {
|
|
281
|
-
console.log(` ${chalk.cyan("yarn
|
|
331
|
+
console.log(` ${chalk.cyan("yarn keys:rotate")} - Rotate cryptographic keys`);
|
|
332
|
+
console.log(` ${chalk.cyan("yarn identity:clean")} - Clean identity data`);
|
|
282
333
|
}
|
|
283
334
|
else if (packageManager === "pnpm") {
|
|
284
|
-
console.log(` ${chalk.cyan("pnpm
|
|
335
|
+
console.log(` ${chalk.cyan("pnpm keys:rotate")} - Rotate cryptographic keys`);
|
|
336
|
+
console.log(` ${chalk.cyan("pnpm identity:clean")} - Clean identity data`);
|
|
285
337
|
}
|
|
286
338
|
else {
|
|
287
|
-
console.log(` ${chalk.cyan("npm run
|
|
339
|
+
console.log(` ${chalk.cyan("npm run keys:rotate")} - Rotate cryptographic keys`);
|
|
340
|
+
console.log(` ${chalk.cyan("npm run identity:clean")} - Clean identity data`);
|
|
288
341
|
}
|
|
289
342
|
}
|
|
290
343
|
console.log();
|
|
291
|
-
console.log("Manage identity:");
|
|
292
|
-
if (resolvedProjectPath !== process.cwd()) {
|
|
293
|
-
console.log(` cd ${chalk.cyan(projectDir)}`);
|
|
294
|
-
}
|
|
295
|
-
// Show identity management commands
|
|
296
|
-
if (packageManager === "yarn") {
|
|
297
|
-
console.log(` ${chalk.cyan("yarn keys:rotate")} - Rotate cryptographic keys`);
|
|
298
|
-
console.log(` ${chalk.cyan("yarn identity:clean")} - Clean identity data`);
|
|
299
|
-
}
|
|
300
|
-
else if (packageManager === "pnpm") {
|
|
301
|
-
console.log(` ${chalk.cyan("pnpm keys:rotate")} - Rotate cryptographic keys`);
|
|
302
|
-
console.log(` ${chalk.cyan("pnpm identity:clean")} - Clean identity data`);
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
console.log(` ${chalk.cyan("npm run keys:rotate")} - Rotate cryptographic keys`);
|
|
306
|
-
console.log(` ${chalk.cyan("npm run identity:clean")} - Clean identity data`);
|
|
307
|
-
}
|
|
308
|
-
console.log();
|
|
309
344
|
// Explicitly exit after successful completion
|
|
310
345
|
process.exit(0);
|
|
311
346
|
}
|