@tinycloud/mcp 0.1.0-beta.2 → 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/dist/cli.cjs +2 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +2 -2
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -221,7 +221,7 @@ function registerTinyCloudTools(server, selection, validator) {
|
|
|
221
221
|
// package.json
|
|
222
222
|
var package_default = {
|
|
223
223
|
name: "@tinycloud/mcp",
|
|
224
|
-
version: "0.1.0
|
|
224
|
+
version: "0.1.0",
|
|
225
225
|
description: "TinyCloud delegated operations MCP server",
|
|
226
226
|
author: "TinyCloud, Inc.",
|
|
227
227
|
license: "EGPL",
|
|
@@ -274,7 +274,7 @@ var package_default = {
|
|
|
274
274
|
},
|
|
275
275
|
dependencies: {
|
|
276
276
|
"@modelcontextprotocol/server": "2.0.0-beta.4",
|
|
277
|
-
"@tinycloud/operations": "0.1.0
|
|
277
|
+
"@tinycloud/operations": "0.1.0"
|
|
278
278
|
},
|
|
279
279
|
devDependencies: {
|
|
280
280
|
"@modelcontextprotocol/client": "2.0.0-beta.4",
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/server.ts","../src/tools.ts","../src/results.ts","../package.json","../src/version.ts"],"sourcesContent":["import { basename } from \"node:path\";\n\nimport { resolveInvocationProfileName } from \"@tinycloud/operations/profile\";\n\nimport { serveTinyCloudMcp, MCP_VERSION } from \"./server.js\";\n\nexport interface ParsedCliOptions {\n readonly profile?: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n readonly help: boolean;\n readonly version: boolean;\n}\n\nconst HELP = `TinyCloud delegated operations MCP server\n\nUsage: tinycloud-mcp [options]\n\nOptions:\n --profile <name> Pin the TinyCloud profile for this process\n --allow-owner-profile Allow data execution for an explicitly selected owner profile\n --help Show this help\n --version Show the package version\n`;\n\nexport function parseCliOptions(arguments_: readonly string[]): ParsedCliOptions {\n let profile: string | undefined;\n let explicitProfile = false;\n let allowOwnerProfile = false;\n let help = false;\n let version = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === \"--help\" || argument === \"-h\") {\n help = true;\n continue;\n }\n if (argument === \"--version\" || argument === \"-v\") {\n version = true;\n continue;\n }\n if (argument === \"--allow-owner-profile\") {\n allowOwnerProfile = true;\n continue;\n }\n if (argument === \"--profile\") {\n const value = arguments_[index + 1];\n if (value === undefined || value.startsWith(\"-\") || value.trim().length === 0) {\n throw new Error(\"--profile requires a non-empty profile name.\");\n }\n profile = value;\n explicitProfile = true;\n index += 1;\n continue;\n }\n if (argument?.startsWith(\"--profile=\")) {\n const value = argument.slice(\"--profile=\".length);\n if (value.trim().length === 0) throw new Error(\"--profile requires a non-empty profile name.\");\n profile = value;\n explicitProfile = true;\n continue;\n }\n throw new Error(`Unknown option: ${argument}`);\n }\n\n return { profile, explicitProfile, allowOwnerProfile, help, version };\n}\n\nexport async function main(arguments_: readonly string[] = process.argv.slice(2)): Promise<number> {\n let options: ParsedCliOptions;\n try {\n options = parseCliOptions(arguments_);\n } catch (error) {\n process.stderr.write(\"[tinycloud-mcp] Invalid command line.\\n\");\n return 2;\n }\n\n if (options.help) {\n process.stdout.write(HELP);\n return 0;\n }\n if (options.version) {\n process.stdout.write(`${MCP_VERSION}\\n`);\n return 0;\n }\n\n let profile: string;\n try {\n profile = await resolveInvocationProfileName(options.profile);\n } catch {\n process.stderr.write(\"[tinycloud-mcp] Could not select a profile.\\n\");\n return 2;\n }\n\n // The selected profile is now a value captured by the server closure. Every\n // operation receives it explicitly and cannot re-read TC_PROFILE/config.\n serveTinyCloudMcp({\n profile,\n explicitProfile: options.explicitProfile,\n allowOwnerProfile: options.allowOwnerProfile,\n });\n return 0;\n}\n\nfunction isDirectInvocation(): boolean {\n const argv = process.argv[1];\n if (argv === undefined) return false;\n return basename(argv) === \"cli.js\" || basename(argv) === \"cli.cjs\" || basename(argv) === \"tinycloud-mcp\";\n}\n\nif (isDirectInvocation()) {\n void main().then((code) => {\n if (code !== 0) process.exitCode = code;\n }).catch(() => {\n process.stderr.write(\"[tinycloud-mcp] Startup failed.\\n\");\n process.exitCode = 1;\n });\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { serveStdio, type StdioServerHandle } from \"@modelcontextprotocol/server/stdio\";\n\nimport { createJsonSchemaValidator, registerTinyCloudTools, type McpStartupSelection } from \"./tools.js\";\nimport { MCP_VERSION } from \"./version.js\";\n\nexport const MCP_SERVER_NAME = \"tinycloud-mcp\";\nexport { MCP_VERSION } from \"./version.js\";\nexport function createTinyCloudMcpServer(selection: McpStartupSelection): McpServer {\n const validator = createJsonSchemaValidator();\n const server = new McpServer(\n { name: MCP_SERVER_NAME, version: MCP_VERSION },\n { jsonSchemaValidator: validator },\n );\n registerTinyCloudTools(server, selection, validator);\n return server;\n}\n\n/** Start the only supported MCP transport: local stdio. */\nexport function serveTinyCloudMcp(selection: McpStartupSelection): StdioServerHandle {\n return serveStdio(\n () => createTinyCloudMcpServer(selection),\n { onerror: () => writeBoundedDiagnostic(\"MCP transport error\") },\n );\n}\n\nfunction writeBoundedDiagnostic(message: string): void {\n process.stderr.write(`[tinycloud-mcp] ${message}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { fromJsonSchema, type McpServer, type ToolAnnotations } from \"@modelcontextprotocol/server\";\nimport { addFormats, Ajv, AjvJsonSchemaValidator } from \"@modelcontextprotocol/server/validators/ajv\";\nimport { invokeOperation } from \"@tinycloud/operations\";\n\nimport { toMcpToolResult, type McpToolResult } from \"./results.js\";\n\nexport const TOOL_NAMES = [\n \"tinycloud_status\",\n \"tinycloud_auth_status\",\n \"tinycloud_auth_capabilities\",\n \"tinycloud_auth_request\",\n \"tinycloud_auth_import\",\n \"tinycloud_account_spaces_list\",\n \"tinycloud_account_applications_list\",\n \"tinycloud_kv_list\",\n \"tinycloud_kv_get\",\n \"tinycloud_secrets_get\",\n] as const;\n\nexport type ToolName = (typeof TOOL_NAMES)[number];\n\nexport interface McpStartupSelection {\n readonly profile: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n}\n\nexport interface McpInvocationTarget {\n readonly profile: string;\n readonly allowOwnerProfile?: true;\n}\n\n/** Project one startup selection into the only owner-sensitive target shape. */\nexport function invocationTargetForMcp(\n selection: McpStartupSelection,\n): McpInvocationTarget {\n return {\n profile: selection.profile,\n ...(selection.explicitProfile && selection.allowOwnerProfile\n ? { allowOwnerProfile: true }\n : {}),\n };\n}\n\ninterface CatalogOperation {\n readonly id: string;\n readonly version: number;\n readonly title: string;\n readonly description: string;\n readonly input: Record<string, unknown>;\n readonly result: Record<string, unknown>;\n}\n\ninterface OperationsCatalog {\n readonly operations: readonly CatalogOperation[];\n}\n\n// The require anchor is this module, never the consumer entrypoint. In ESM\n// tsup preserves import.meta.url; in CJS it rewrites the same module-relative\n// anchor to the generated __filename, so both formats stay in MCP's package\n// dependency boundary.\nconst packageRequire = createRequire(\n typeof __dirname === \"string\" ? join(__dirname, \"tools.cjs\") : import.meta.url,\n);\nconst generatedCatalog = packageRequire(\n \"@tinycloud/operations/operations.json\",\n) as OperationsCatalog;\n\ninterface ToolBinding {\n readonly name: ToolName;\n readonly operationId: string;\n readonly operationVersion: number;\n readonly readOnlyHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n}\n\nconst TOOL_BINDINGS: readonly ToolBinding[] = [\n {\n name: \"tinycloud_status\",\n operationId: \"tinycloud.status.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_status\",\n operationId: \"tinycloud.auth.status\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_capabilities\",\n operationId: \"tinycloud.auth.capabilities\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_request\",\n operationId: \"tinycloud.auth.request\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_import\",\n operationId: \"tinycloud.auth.import\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_account_spaces_list\",\n operationId: \"tinycloud.account.spaces.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_account_applications_list\",\n operationId: \"tinycloud.account.applications.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_list\",\n operationId: \"tinycloud.kv.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_get\",\n operationId: \"tinycloud.kv.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_secrets_get\",\n operationId: \"tinycloud.secrets.get\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: true,\n },\n] as const;\n\nexport function createJsonSchemaValidator(): AjvJsonSchemaValidator {\n const ajv = new Ajv({ strict: false });\n addFormats(ajv);\n return new AjvJsonSchemaValidator(ajv);\n}\n\nexport function registerTinyCloudTools(\n server: McpServer,\n selection: McpStartupSelection,\n validator: AjvJsonSchemaValidator,\n): void {\n const definitions = new Map(\n generatedCatalog.operations.map((operation) => [\n `${operation.id}@${operation.version}`,\n operation,\n ]),\n );\n\n for (const binding of TOOL_BINDINGS) {\n const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);\n if (operation === undefined) {\n throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);\n }\n\n const inputSchema = fromJsonSchema(\n operation.input as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const outputSchema = fromJsonSchema(\n operation.result as unknown as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const annotations: ToolAnnotations = {\n readOnlyHint: binding.readOnlyHint,\n idempotentHint: binding.idempotentHint,\n destructiveHint: false,\n openWorldHint: binding.openWorldHint,\n };\n\n server.registerTool(\n binding.name,\n {\n title: operation.title,\n description: operation.description,\n inputSchema,\n outputSchema,\n annotations,\n },\n async (input: unknown): Promise<McpToolResult> => {\n const result = await invokeOperation(\n binding.operationId,\n binding.operationVersion,\n invocationTargetForMcp(selection),\n input,\n );\n return toMcpToolResult(result);\n },\n );\n }\n}\n\nexport function toolBindingsForTest(): readonly ToolBinding[] {\n return TOOL_BINDINGS;\n}\n","/**\n * MCP has one structured result channel for a TinyCloud operation. Text is a\n * fixed, non-sensitive status line; it never serializes the operation result.\n */\nexport interface CanonicalOperationResult {\n readonly status: \"ok\" | \"authority_required\" | \"setup_required\" | \"error\";\n readonly [key: string]: unknown;\n}\n\nexport interface McpToolResult extends CallToolResult {\n readonly content: [{ readonly type: \"text\"; readonly text: string }];\n readonly structuredContent: CanonicalOperationResult;\n}\n\nexport function toMcpToolResult(result: unknown): McpToolResult {\n const canonical: CanonicalOperationResult = isCanonicalOperationResult(result)\n ? result\n : {\n status: \"error\",\n operation: {},\n context: {},\n error: { code: \"INTERNAL_ERROR\" },\n };\n\n return {\n content: [{ type: \"text\", text: resultSummary(canonical.status) }],\n structuredContent: canonical,\n };\n}\n\n/** The canonical envelope immediately before MCP protocol serialization. */\nexport function canonicalMcpAdapterResult(result: unknown): CanonicalOperationResult {\n return toMcpToolResult(result).structuredContent;\n}\n\nfunction isCanonicalOperationResult(value: unknown): value is CanonicalOperationResult {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const status = (value as { status?: unknown }).status;\n return status === \"ok\" ||\n status === \"authority_required\" ||\n status === \"setup_required\" ||\n status === \"error\";\n}\n\nfunction resultSummary(status: CanonicalOperationResult[\"status\"]): string {\n switch (status) {\n case \"ok\":\n return \"TinyCloud operation completed; use the structured result.\";\n case \"authority_required\":\n return \"TinyCloud authority is required; use the structured request and approval action.\";\n case \"setup_required\":\n return \"TinyCloud setup is required; use the structured setup action.\";\n case \"error\":\n return \"TinyCloud operation failed; use the structured error.\";\n }\n}\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n","{\n \"name\": \"@tinycloud/mcp\",\n \"version\": \"0.1.0-beta.2\",\n \"description\": \"TinyCloud delegated operations MCP server\",\n \"author\": \"TinyCloud, Inc.\",\n \"license\": \"EGPL\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"tinycloud-mcp\": \"./bin/tinycloud-mcp\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"types\": \"./dist/server.d.ts\",\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./tools\": {\n \"types\": \"./dist/tools.d.ts\",\n \"import\": \"./dist/tools.js\",\n \"require\": \"./dist/tools.cjs\"\n },\n \"./results\": {\n \"types\": \"./dist/results.d.ts\",\n \"import\": \"./dist/results.js\",\n \"require\": \"./dist/results.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"generated\",\n \"skills\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"bun run build && bun scripts/test.ts && bun run check:generated\",\n \"test:stdio\": \"bun run build && bun test src/stdio.test.ts\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"generate\": \"bun scripts/generate.ts\",\n \"check:generated\": \"bun scripts/generate.ts --check\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/server\": \"2.0.0-beta.4\",\n \"@tinycloud/operations\": \"0.1.0-beta.2\"\n },\n \"devDependencies\": {\n \"@modelcontextprotocol/client\": \"2.0.0-beta.4\",\n \"@types/node\": \"^20\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/tinycloudlabs/web-sdk\"\n }\n}\n","import packageMetadata from \"../package.json\";\n\nexport const MCP_VERSION = packageMetadata.version;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,oBAAyB;AAEzB,qBAA6C;;;ACF7C,IAAAC,iBAA0B;AAC1B,mBAAmD;;;ACDnD,yBAA8B;AAC9B,uBAAqB;AAErB,oBAAqE;AACrE,iBAAwD;AACxD,wBAAgC;;;ACSzB,SAAS,gBAAgB,QAAgC;AAC9D,QAAM,YAAsC,2BAA2B,MAAM,IACzE,SACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW,CAAC;AAAA,IACZ,SAAS,CAAC;AAAA,IACV,OAAO,EAAE,MAAM,iBAAiB;AAAA,EAClC;AAEF,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,cAAc,UAAU,MAAM,EAAE,CAAC;AAAA,IACjE,mBAAmB;AAAA,EACrB;AACF;AAOA,SAAS,2BAA2B,OAAmD;AACrF,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,SAAU,MAA+B;AAC/C,SAAO,WAAW,QAChB,WAAW,wBACX,WAAW,oBACX,WAAW;AACf;AA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AAC;AAC3B,MAAI,SAAS,OAAW,QAAO;AAC/B,aAAO,4BAAS,IAAI,MAAM,gBAAY,4BAAS,IAAI,MAAM,iBAAa,4BAAS,IAAI,MAAM;AAC3F;AAEA,IAAI,mBAAmB,GAAG;AACxB,OAAK,KAAK,EAAE,KAAK,CAAC,SAAS;AACzB,QAAI,SAAS,EAAG,SAAQ,WAAW;AAAA,EACrC,CAAC,EAAE,MAAM,MAAM;AACb,YAAQ,OAAO,MAAM,mCAAmC;AACxD,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":["import_node_path","import_server"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/server.ts","../src/tools.ts","../src/results.ts","../package.json","../src/version.ts"],"sourcesContent":["import { basename } from \"node:path\";\n\nimport { resolveInvocationProfileName } from \"@tinycloud/operations/profile\";\n\nimport { serveTinyCloudMcp, MCP_VERSION } from \"./server.js\";\n\nexport interface ParsedCliOptions {\n readonly profile?: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n readonly help: boolean;\n readonly version: boolean;\n}\n\nconst HELP = `TinyCloud delegated operations MCP server\n\nUsage: tinycloud-mcp [options]\n\nOptions:\n --profile <name> Pin the TinyCloud profile for this process\n --allow-owner-profile Allow data execution for an explicitly selected owner profile\n --help Show this help\n --version Show the package version\n`;\n\nexport function parseCliOptions(arguments_: readonly string[]): ParsedCliOptions {\n let profile: string | undefined;\n let explicitProfile = false;\n let allowOwnerProfile = false;\n let help = false;\n let version = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === \"--help\" || argument === \"-h\") {\n help = true;\n continue;\n }\n if (argument === \"--version\" || argument === \"-v\") {\n version = true;\n continue;\n }\n if (argument === \"--allow-owner-profile\") {\n allowOwnerProfile = true;\n continue;\n }\n if (argument === \"--profile\") {\n const value = arguments_[index + 1];\n if (value === undefined || value.startsWith(\"-\") || value.trim().length === 0) {\n throw new Error(\"--profile requires a non-empty profile name.\");\n }\n profile = value;\n explicitProfile = true;\n index += 1;\n continue;\n }\n if (argument?.startsWith(\"--profile=\")) {\n const value = argument.slice(\"--profile=\".length);\n if (value.trim().length === 0) throw new Error(\"--profile requires a non-empty profile name.\");\n profile = value;\n explicitProfile = true;\n continue;\n }\n throw new Error(`Unknown option: ${argument}`);\n }\n\n return { profile, explicitProfile, allowOwnerProfile, help, version };\n}\n\nexport async function main(arguments_: readonly string[] = process.argv.slice(2)): Promise<number> {\n let options: ParsedCliOptions;\n try {\n options = parseCliOptions(arguments_);\n } catch (error) {\n process.stderr.write(\"[tinycloud-mcp] Invalid command line.\\n\");\n return 2;\n }\n\n if (options.help) {\n process.stdout.write(HELP);\n return 0;\n }\n if (options.version) {\n process.stdout.write(`${MCP_VERSION}\\n`);\n return 0;\n }\n\n let profile: string;\n try {\n profile = await resolveInvocationProfileName(options.profile);\n } catch {\n process.stderr.write(\"[tinycloud-mcp] Could not select a profile.\\n\");\n return 2;\n }\n\n // The selected profile is now a value captured by the server closure. Every\n // operation receives it explicitly and cannot re-read TC_PROFILE/config.\n serveTinyCloudMcp({\n profile,\n explicitProfile: options.explicitProfile,\n allowOwnerProfile: options.allowOwnerProfile,\n });\n return 0;\n}\n\nfunction isDirectInvocation(): boolean {\n const argv = process.argv[1];\n if (argv === undefined) return false;\n return basename(argv) === \"cli.js\" || basename(argv) === \"cli.cjs\" || basename(argv) === \"tinycloud-mcp\";\n}\n\nif (isDirectInvocation()) {\n void main().then((code) => {\n if (code !== 0) process.exitCode = code;\n }).catch(() => {\n process.stderr.write(\"[tinycloud-mcp] Startup failed.\\n\");\n process.exitCode = 1;\n });\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { serveStdio, type StdioServerHandle } from \"@modelcontextprotocol/server/stdio\";\n\nimport { createJsonSchemaValidator, registerTinyCloudTools, type McpStartupSelection } from \"./tools.js\";\nimport { MCP_VERSION } from \"./version.js\";\n\nexport const MCP_SERVER_NAME = \"tinycloud-mcp\";\nexport { MCP_VERSION } from \"./version.js\";\nexport function createTinyCloudMcpServer(selection: McpStartupSelection): McpServer {\n const validator = createJsonSchemaValidator();\n const server = new McpServer(\n { name: MCP_SERVER_NAME, version: MCP_VERSION },\n { jsonSchemaValidator: validator },\n );\n registerTinyCloudTools(server, selection, validator);\n return server;\n}\n\n/** Start the only supported MCP transport: local stdio. */\nexport function serveTinyCloudMcp(selection: McpStartupSelection): StdioServerHandle {\n return serveStdio(\n () => createTinyCloudMcpServer(selection),\n { onerror: () => writeBoundedDiagnostic(\"MCP transport error\") },\n );\n}\n\nfunction writeBoundedDiagnostic(message: string): void {\n process.stderr.write(`[tinycloud-mcp] ${message}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { fromJsonSchema, type McpServer, type ToolAnnotations } from \"@modelcontextprotocol/server\";\nimport { addFormats, Ajv, AjvJsonSchemaValidator } from \"@modelcontextprotocol/server/validators/ajv\";\nimport { invokeOperation } from \"@tinycloud/operations\";\n\nimport { toMcpToolResult, type McpToolResult } from \"./results.js\";\n\nexport const TOOL_NAMES = [\n \"tinycloud_status\",\n \"tinycloud_auth_status\",\n \"tinycloud_auth_capabilities\",\n \"tinycloud_auth_request\",\n \"tinycloud_auth_import\",\n \"tinycloud_account_spaces_list\",\n \"tinycloud_account_applications_list\",\n \"tinycloud_kv_list\",\n \"tinycloud_kv_get\",\n \"tinycloud_secrets_get\",\n] as const;\n\nexport type ToolName = (typeof TOOL_NAMES)[number];\n\nexport interface McpStartupSelection {\n readonly profile: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n}\n\nexport interface McpInvocationTarget {\n readonly profile: string;\n readonly allowOwnerProfile?: true;\n}\n\n/** Project one startup selection into the only owner-sensitive target shape. */\nexport function invocationTargetForMcp(\n selection: McpStartupSelection,\n): McpInvocationTarget {\n return {\n profile: selection.profile,\n ...(selection.explicitProfile && selection.allowOwnerProfile\n ? { allowOwnerProfile: true }\n : {}),\n };\n}\n\ninterface CatalogOperation {\n readonly id: string;\n readonly version: number;\n readonly title: string;\n readonly description: string;\n readonly input: Record<string, unknown>;\n readonly result: Record<string, unknown>;\n}\n\ninterface OperationsCatalog {\n readonly operations: readonly CatalogOperation[];\n}\n\n// The require anchor is this module, never the consumer entrypoint. In ESM\n// tsup preserves import.meta.url; in CJS it rewrites the same module-relative\n// anchor to the generated __filename, so both formats stay in MCP's package\n// dependency boundary.\nconst packageRequire = createRequire(\n typeof __dirname === \"string\" ? join(__dirname, \"tools.cjs\") : import.meta.url,\n);\nconst generatedCatalog = packageRequire(\n \"@tinycloud/operations/operations.json\",\n) as OperationsCatalog;\n\ninterface ToolBinding {\n readonly name: ToolName;\n readonly operationId: string;\n readonly operationVersion: number;\n readonly readOnlyHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n}\n\nconst TOOL_BINDINGS: readonly ToolBinding[] = [\n {\n name: \"tinycloud_status\",\n operationId: \"tinycloud.status.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_status\",\n operationId: \"tinycloud.auth.status\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_capabilities\",\n operationId: \"tinycloud.auth.capabilities\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_request\",\n operationId: \"tinycloud.auth.request\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_import\",\n operationId: \"tinycloud.auth.import\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_account_spaces_list\",\n operationId: \"tinycloud.account.spaces.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_account_applications_list\",\n operationId: \"tinycloud.account.applications.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_list\",\n operationId: \"tinycloud.kv.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_get\",\n operationId: \"tinycloud.kv.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_secrets_get\",\n operationId: \"tinycloud.secrets.get\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: true,\n },\n] as const;\n\nexport function createJsonSchemaValidator(): AjvJsonSchemaValidator {\n const ajv = new Ajv({ strict: false });\n addFormats(ajv);\n return new AjvJsonSchemaValidator(ajv);\n}\n\nexport function registerTinyCloudTools(\n server: McpServer,\n selection: McpStartupSelection,\n validator: AjvJsonSchemaValidator,\n): void {\n const definitions = new Map(\n generatedCatalog.operations.map((operation) => [\n `${operation.id}@${operation.version}`,\n operation,\n ]),\n );\n\n for (const binding of TOOL_BINDINGS) {\n const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);\n if (operation === undefined) {\n throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);\n }\n\n const inputSchema = fromJsonSchema(\n operation.input as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const outputSchema = fromJsonSchema(\n operation.result as unknown as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const annotations: ToolAnnotations = {\n readOnlyHint: binding.readOnlyHint,\n idempotentHint: binding.idempotentHint,\n destructiveHint: false,\n openWorldHint: binding.openWorldHint,\n };\n\n server.registerTool(\n binding.name,\n {\n title: operation.title,\n description: operation.description,\n inputSchema,\n outputSchema,\n annotations,\n },\n async (input: unknown): Promise<McpToolResult> => {\n const result = await invokeOperation(\n binding.operationId,\n binding.operationVersion,\n invocationTargetForMcp(selection),\n input,\n );\n return toMcpToolResult(result);\n },\n );\n }\n}\n\nexport function toolBindingsForTest(): readonly ToolBinding[] {\n return TOOL_BINDINGS;\n}\n","/**\n * MCP has one structured result channel for a TinyCloud operation. Text is a\n * fixed, non-sensitive status line; it never serializes the operation result.\n */\nexport interface CanonicalOperationResult {\n readonly status: \"ok\" | \"authority_required\" | \"setup_required\" | \"error\";\n readonly [key: string]: unknown;\n}\n\nexport interface McpToolResult extends CallToolResult {\n readonly content: [{ readonly type: \"text\"; readonly text: string }];\n readonly structuredContent: CanonicalOperationResult;\n}\n\nexport function toMcpToolResult(result: unknown): McpToolResult {\n const canonical: CanonicalOperationResult = isCanonicalOperationResult(result)\n ? result\n : {\n status: \"error\",\n operation: {},\n context: {},\n error: { code: \"INTERNAL_ERROR\" },\n };\n\n return {\n content: [{ type: \"text\", text: resultSummary(canonical.status) }],\n structuredContent: canonical,\n };\n}\n\n/** The canonical envelope immediately before MCP protocol serialization. */\nexport function canonicalMcpAdapterResult(result: unknown): CanonicalOperationResult {\n return toMcpToolResult(result).structuredContent;\n}\n\nfunction isCanonicalOperationResult(value: unknown): value is CanonicalOperationResult {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const status = (value as { status?: unknown }).status;\n return status === \"ok\" ||\n status === \"authority_required\" ||\n status === \"setup_required\" ||\n status === \"error\";\n}\n\nfunction resultSummary(status: CanonicalOperationResult[\"status\"]): string {\n switch (status) {\n case \"ok\":\n return \"TinyCloud operation completed; use the structured result.\";\n case \"authority_required\":\n return \"TinyCloud authority is required; use the structured request and approval action.\";\n case \"setup_required\":\n return \"TinyCloud setup is required; use the structured setup action.\";\n case \"error\":\n return \"TinyCloud operation failed; use the structured error.\";\n }\n}\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n","{\n \"name\": \"@tinycloud/mcp\",\n \"version\": \"0.1.0\",\n \"description\": \"TinyCloud delegated operations MCP server\",\n \"author\": \"TinyCloud, Inc.\",\n \"license\": \"EGPL\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"tinycloud-mcp\": \"./bin/tinycloud-mcp\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"types\": \"./dist/server.d.ts\",\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./tools\": {\n \"types\": \"./dist/tools.d.ts\",\n \"import\": \"./dist/tools.js\",\n \"require\": \"./dist/tools.cjs\"\n },\n \"./results\": {\n \"types\": \"./dist/results.d.ts\",\n \"import\": \"./dist/results.js\",\n \"require\": \"./dist/results.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"generated\",\n \"skills\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"bun run build && bun scripts/test.ts && bun run check:generated\",\n \"test:stdio\": \"bun run build && bun test src/stdio.test.ts\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"generate\": \"bun scripts/generate.ts\",\n \"check:generated\": \"bun scripts/generate.ts --check\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/server\": \"2.0.0-beta.4\",\n \"@tinycloud/operations\": \"0.1.0\"\n },\n \"devDependencies\": {\n \"@modelcontextprotocol/client\": \"2.0.0-beta.4\",\n \"@types/node\": \"^20\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/tinycloudlabs/web-sdk\"\n }\n}\n","import packageMetadata from \"../package.json\";\n\nexport const MCP_VERSION = packageMetadata.version;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,oBAAyB;AAEzB,qBAA6C;;;ACF7C,IA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B;AACjG,MAAI;AACJ,MAAI;AACF,cAAU,gBAAgB,UAAU;AAAA,EACtC,SAAS,OAAO;AACd,YAAQ,OAAO,MAAM,yCAAyC;AAC9D,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,MAAM;AAChB,YAAQ,OAAO,MAAM,IAAI;AACzB,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,SAAS;AACnB,YAAQ,OAAO,MAAM,GAAG,WAAW;AAAA,CAAI;AACvC,WAAO;AAAA,EACT;AAEA,MAAI;AACJ,MAAI;AACF,cAAU,UAAM,6CAA6B,QAAQ,OAAO;AAAA,EAC9D,QAAQ;AACN,YAAQ,OAAO,MAAM,+CAA+C;AACpE,WAAO;AAAA,EACT;AAIA,oBAAkB;AAAA,IAChB;AAAA,IACA,iBAAiB,QAAQ;AAAA,IACzB,mBAAmB,QAAQ;AAAA,EAC7B,CAAC;AACD,SAAO;AACT;AAEA,SAAS,qBAA8B;AACrC,QAAM,OAAO,QAAQ,KAAK,CAAC;AAC3B,MAAI,SAAS,OAAW,QAAO;AAC/B,aAAO,4BAAS,IAAI,MAAM,gBAAY,4BAAS,IAAI,MAAM,iBAAa,4BAAS,IAAI,MAAM;AAC3F;AAEA,IAAI,mBAAmB,GAAG;AACxB,OAAK,KAAK,EAAE,KAAK,CAAC,SAAS;AACzB,QAAI,SAAS,EAAG,SAAQ,WAAW;AAAA,EACrC,CAAC,EAAE,MAAM,MAAM;AACb,YAAQ,OAAO,MAAM,mCAAmC;AACxD,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":["import_node_path","import_server"]}
|
package/dist/cli.js
CHANGED
|
@@ -195,7 +195,7 @@ function registerTinyCloudTools(server, selection, validator) {
|
|
|
195
195
|
// package.json
|
|
196
196
|
var package_default = {
|
|
197
197
|
name: "@tinycloud/mcp",
|
|
198
|
-
version: "0.1.0
|
|
198
|
+
version: "0.1.0",
|
|
199
199
|
description: "TinyCloud delegated operations MCP server",
|
|
200
200
|
author: "TinyCloud, Inc.",
|
|
201
201
|
license: "EGPL",
|
|
@@ -248,7 +248,7 @@ var package_default = {
|
|
|
248
248
|
},
|
|
249
249
|
dependencies: {
|
|
250
250
|
"@modelcontextprotocol/server": "2.0.0-beta.4",
|
|
251
|
-
"@tinycloud/operations": "0.1.0
|
|
251
|
+
"@tinycloud/operations": "0.1.0"
|
|
252
252
|
},
|
|
253
253
|
devDependencies: {
|
|
254
254
|
"@modelcontextprotocol/client": "2.0.0-beta.4",
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/server.ts","../src/tools.ts","../src/results.ts","../package.json","../src/version.ts"],"sourcesContent":["import { basename } from \"node:path\";\n\nimport { resolveInvocationProfileName } from \"@tinycloud/operations/profile\";\n\nimport { serveTinyCloudMcp, MCP_VERSION } from \"./server.js\";\n\nexport interface ParsedCliOptions {\n readonly profile?: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n readonly help: boolean;\n readonly version: boolean;\n}\n\nconst HELP = `TinyCloud delegated operations MCP server\n\nUsage: tinycloud-mcp [options]\n\nOptions:\n --profile <name> Pin the TinyCloud profile for this process\n --allow-owner-profile Allow data execution for an explicitly selected owner profile\n --help Show this help\n --version Show the package version\n`;\n\nexport function parseCliOptions(arguments_: readonly string[]): ParsedCliOptions {\n let profile: string | undefined;\n let explicitProfile = false;\n let allowOwnerProfile = false;\n let help = false;\n let version = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === \"--help\" || argument === \"-h\") {\n help = true;\n continue;\n }\n if (argument === \"--version\" || argument === \"-v\") {\n version = true;\n continue;\n }\n if (argument === \"--allow-owner-profile\") {\n allowOwnerProfile = true;\n continue;\n }\n if (argument === \"--profile\") {\n const value = arguments_[index + 1];\n if (value === undefined || value.startsWith(\"-\") || value.trim().length === 0) {\n throw new Error(\"--profile requires a non-empty profile name.\");\n }\n profile = value;\n explicitProfile = true;\n index += 1;\n continue;\n }\n if (argument?.startsWith(\"--profile=\")) {\n const value = argument.slice(\"--profile=\".length);\n if (value.trim().length === 0) throw new Error(\"--profile requires a non-empty profile name.\");\n profile = value;\n explicitProfile = true;\n continue;\n }\n throw new Error(`Unknown option: ${argument}`);\n }\n\n return { profile, explicitProfile, allowOwnerProfile, help, version };\n}\n\nexport async function main(arguments_: readonly string[] = process.argv.slice(2)): Promise<number> {\n let options: ParsedCliOptions;\n try {\n options = parseCliOptions(arguments_);\n } catch (error) {\n process.stderr.write(\"[tinycloud-mcp] Invalid command line.\\n\");\n return 2;\n }\n\n if (options.help) {\n process.stdout.write(HELP);\n return 0;\n }\n if (options.version) {\n process.stdout.write(`${MCP_VERSION}\\n`);\n return 0;\n }\n\n let profile: string;\n try {\n profile = await resolveInvocationProfileName(options.profile);\n } catch {\n process.stderr.write(\"[tinycloud-mcp] Could not select a profile.\\n\");\n return 2;\n }\n\n // The selected profile is now a value captured by the server closure. Every\n // operation receives it explicitly and cannot re-read TC_PROFILE/config.\n serveTinyCloudMcp({\n profile,\n explicitProfile: options.explicitProfile,\n allowOwnerProfile: options.allowOwnerProfile,\n });\n return 0;\n}\n\nfunction isDirectInvocation(): boolean {\n const argv = process.argv[1];\n if (argv === undefined) return false;\n return basename(argv) === \"cli.js\" || basename(argv) === \"cli.cjs\" || basename(argv) === \"tinycloud-mcp\";\n}\n\nif (isDirectInvocation()) {\n void main().then((code) => {\n if (code !== 0) process.exitCode = code;\n }).catch(() => {\n process.stderr.write(\"[tinycloud-mcp] Startup failed.\\n\");\n process.exitCode = 1;\n });\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { serveStdio, type StdioServerHandle } from \"@modelcontextprotocol/server/stdio\";\n\nimport { createJsonSchemaValidator, registerTinyCloudTools, type McpStartupSelection } from \"./tools.js\";\nimport { MCP_VERSION } from \"./version.js\";\n\nexport const MCP_SERVER_NAME = \"tinycloud-mcp\";\nexport { MCP_VERSION } from \"./version.js\";\nexport function createTinyCloudMcpServer(selection: McpStartupSelection): McpServer {\n const validator = createJsonSchemaValidator();\n const server = new McpServer(\n { name: MCP_SERVER_NAME, version: MCP_VERSION },\n { jsonSchemaValidator: validator },\n );\n registerTinyCloudTools(server, selection, validator);\n return server;\n}\n\n/** Start the only supported MCP transport: local stdio. */\nexport function serveTinyCloudMcp(selection: McpStartupSelection): StdioServerHandle {\n return serveStdio(\n () => createTinyCloudMcpServer(selection),\n { onerror: () => writeBoundedDiagnostic(\"MCP transport error\") },\n );\n}\n\nfunction writeBoundedDiagnostic(message: string): void {\n process.stderr.write(`[tinycloud-mcp] ${message}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { fromJsonSchema, type McpServer, type ToolAnnotations } from \"@modelcontextprotocol/server\";\nimport { addFormats, Ajv, AjvJsonSchemaValidator } from \"@modelcontextprotocol/server/validators/ajv\";\nimport { invokeOperation } from \"@tinycloud/operations\";\n\nimport { toMcpToolResult, type McpToolResult } from \"./results.js\";\n\nexport const TOOL_NAMES = [\n \"tinycloud_status\",\n \"tinycloud_auth_status\",\n \"tinycloud_auth_capabilities\",\n \"tinycloud_auth_request\",\n \"tinycloud_auth_import\",\n \"tinycloud_account_spaces_list\",\n \"tinycloud_account_applications_list\",\n \"tinycloud_kv_list\",\n \"tinycloud_kv_get\",\n \"tinycloud_secrets_get\",\n] as const;\n\nexport type ToolName = (typeof TOOL_NAMES)[number];\n\nexport interface McpStartupSelection {\n readonly profile: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n}\n\nexport interface McpInvocationTarget {\n readonly profile: string;\n readonly allowOwnerProfile?: true;\n}\n\n/** Project one startup selection into the only owner-sensitive target shape. */\nexport function invocationTargetForMcp(\n selection: McpStartupSelection,\n): McpInvocationTarget {\n return {\n profile: selection.profile,\n ...(selection.explicitProfile && selection.allowOwnerProfile\n ? { allowOwnerProfile: true }\n : {}),\n };\n}\n\ninterface CatalogOperation {\n readonly id: string;\n readonly version: number;\n readonly title: string;\n readonly description: string;\n readonly input: Record<string, unknown>;\n readonly result: Record<string, unknown>;\n}\n\ninterface OperationsCatalog {\n readonly operations: readonly CatalogOperation[];\n}\n\n// The require anchor is this module, never the consumer entrypoint. In ESM\n// tsup preserves import.meta.url; in CJS it rewrites the same module-relative\n// anchor to the generated __filename, so both formats stay in MCP's package\n// dependency boundary.\nconst packageRequire = createRequire(\n typeof __dirname === \"string\" ? join(__dirname, \"tools.cjs\") : import.meta.url,\n);\nconst generatedCatalog = packageRequire(\n \"@tinycloud/operations/operations.json\",\n) as OperationsCatalog;\n\ninterface ToolBinding {\n readonly name: ToolName;\n readonly operationId: string;\n readonly operationVersion: number;\n readonly readOnlyHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n}\n\nconst TOOL_BINDINGS: readonly ToolBinding[] = [\n {\n name: \"tinycloud_status\",\n operationId: \"tinycloud.status.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_status\",\n operationId: \"tinycloud.auth.status\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_capabilities\",\n operationId: \"tinycloud.auth.capabilities\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_request\",\n operationId: \"tinycloud.auth.request\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_import\",\n operationId: \"tinycloud.auth.import\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_account_spaces_list\",\n operationId: \"tinycloud.account.spaces.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_account_applications_list\",\n operationId: \"tinycloud.account.applications.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_list\",\n operationId: \"tinycloud.kv.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_get\",\n operationId: \"tinycloud.kv.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_secrets_get\",\n operationId: \"tinycloud.secrets.get\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: true,\n },\n] as const;\n\nexport function createJsonSchemaValidator(): AjvJsonSchemaValidator {\n const ajv = new Ajv({ strict: false });\n addFormats(ajv);\n return new AjvJsonSchemaValidator(ajv);\n}\n\nexport function registerTinyCloudTools(\n server: McpServer,\n selection: McpStartupSelection,\n validator: AjvJsonSchemaValidator,\n): void {\n const definitions = new Map(\n generatedCatalog.operations.map((operation) => [\n `${operation.id}@${operation.version}`,\n operation,\n ]),\n );\n\n for (const binding of TOOL_BINDINGS) {\n const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);\n if (operation === undefined) {\n throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);\n }\n\n const inputSchema = fromJsonSchema(\n operation.input as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const outputSchema = fromJsonSchema(\n operation.result as unknown as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const annotations: ToolAnnotations = {\n readOnlyHint: binding.readOnlyHint,\n idempotentHint: binding.idempotentHint,\n destructiveHint: false,\n openWorldHint: binding.openWorldHint,\n };\n\n server.registerTool(\n binding.name,\n {\n title: operation.title,\n description: operation.description,\n inputSchema,\n outputSchema,\n annotations,\n },\n async (input: unknown): Promise<McpToolResult> => {\n const result = await invokeOperation(\n binding.operationId,\n binding.operationVersion,\n invocationTargetForMcp(selection),\n input,\n );\n return toMcpToolResult(result);\n },\n );\n }\n}\n\nexport function toolBindingsForTest(): readonly ToolBinding[] {\n return TOOL_BINDINGS;\n}\n","/**\n * MCP has one structured result channel for a TinyCloud operation. Text is a\n * fixed, non-sensitive status line; it never serializes the operation result.\n */\nexport interface CanonicalOperationResult {\n readonly status: \"ok\" | \"authority_required\" | \"setup_required\" | \"error\";\n readonly [key: string]: unknown;\n}\n\nexport interface McpToolResult extends CallToolResult {\n readonly content: [{ readonly type: \"text\"; readonly text: string }];\n readonly structuredContent: CanonicalOperationResult;\n}\n\nexport function toMcpToolResult(result: unknown): McpToolResult {\n const canonical: CanonicalOperationResult = isCanonicalOperationResult(result)\n ? result\n : {\n status: \"error\",\n operation: {},\n context: {},\n error: { code: \"INTERNAL_ERROR\" },\n };\n\n return {\n content: [{ type: \"text\", text: resultSummary(canonical.status) }],\n structuredContent: canonical,\n };\n}\n\n/** The canonical envelope immediately before MCP protocol serialization. */\nexport function canonicalMcpAdapterResult(result: unknown): CanonicalOperationResult {\n return toMcpToolResult(result).structuredContent;\n}\n\nfunction isCanonicalOperationResult(value: unknown): value is CanonicalOperationResult {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const status = (value as { status?: unknown }).status;\n return status === \"ok\" ||\n status === \"authority_required\" ||\n status === \"setup_required\" ||\n status === \"error\";\n}\n\nfunction resultSummary(status: CanonicalOperationResult[\"status\"]): string {\n switch (status) {\n case \"ok\":\n return \"TinyCloud operation completed; use the structured result.\";\n case \"authority_required\":\n return \"TinyCloud authority is required; use the structured request and approval action.\";\n case \"setup_required\":\n return \"TinyCloud setup is required; use the structured setup action.\";\n case \"error\":\n return \"TinyCloud operation failed; use the structured error.\";\n }\n}\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n","{\n \"name\": \"@tinycloud/mcp\",\n \"version\": \"0.1.0-beta.2\",\n \"description\": \"TinyCloud delegated operations MCP server\",\n \"author\": \"TinyCloud, Inc.\",\n \"license\": \"EGPL\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"tinycloud-mcp\": \"./bin/tinycloud-mcp\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"types\": \"./dist/server.d.ts\",\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./tools\": {\n \"types\": \"./dist/tools.d.ts\",\n \"import\": \"./dist/tools.js\",\n \"require\": \"./dist/tools.cjs\"\n },\n \"./results\": {\n \"types\": \"./dist/results.d.ts\",\n \"import\": \"./dist/results.js\",\n \"require\": \"./dist/results.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"generated\",\n \"skills\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"bun run build && bun scripts/test.ts && bun run check:generated\",\n \"test:stdio\": \"bun run build && bun test src/stdio.test.ts\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"generate\": \"bun scripts/generate.ts\",\n \"check:generated\": \"bun scripts/generate.ts --check\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/server\": \"2.0.0-beta.4\",\n \"@tinycloud/operations\": \"0.1.0-beta.2\"\n },\n \"devDependencies\": {\n \"@modelcontextprotocol/client\": \"2.0.0-beta.4\",\n \"@types/node\": \"^20\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/tinycloudlabs/web-sdk\"\n }\n}\n","import packageMetadata from \"../package.json\";\n\nexport const MCP_VERSION = packageMetadata.version;\n"],"mappings":";AAAA,SAAS,gBAAgB;AAEzB,SAAS,oCAAoC;;;ACF7C,SAAS,iBAAiB;AAC1B,SAAS,kBAA0C;;;ACDnD,SAAS,qBAAqB;AAC9B,SAAS,YAA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gB,UAAU;AAAA,EACtC,SAAS,OAAO;AACd,YAAQ,OAAO,MAAM,yCAAyC;AAC9D,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,MAAM;AAChB,YAAQ,OAAO,MAAM,IAAI;AACzB,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,SAAS;AACnB,YAAQ,OAAO,MAAM,GAAG,WAAW;AAAA,CAAI;AACvC,WAAO;AAAA,EACT;AAEA,MAAI;AACJ,MAAI;AACF,cAAU,MAAM,6BAA6B,QAAQ,OAAO;AAAA,EAC9D,QAAQ;AACN,YAAQ,OAAO,MAAM,+CAA+C;AACpE,WAAO;AAAA,EACT;AAIA,oBAAkB;AAAA,IAChB;AAAA,IACA,iBAAiB,QAAQ;AAAA,IACzB,mBAAmB,QAAQ;AAAA,EAC7B,CAAC;AACD,SAAO;AACT;AAEA,SAAS,qBAA8B;AACrC,QAAM,OAAO,QAAQ,KAAK,CAAC;AAC3B,MAAI,SAAS,OAAW,QAAO;AAC/B,SAAO,SAAS,IAAI,MAAM,YAAY,SAAS,IAAI,MAAM,aAAa,SAAS,IAAI,MAAM;AAC3F;AAEA,IAAI,mBAAmB,GAAG;AACxB,OAAK,KAAK,EAAE,KAAK,CAAC,SAAS;AACzB,QAAI,SAAS,EAAG,SAAQ,WAAW;AAAA,EACrC,CAAC,EAAE,MAAM,MAAM;AACb,YAAQ,OAAO,MAAM,mCAAmC;AACxD,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/server.ts","../src/tools.ts","../src/results.ts","../package.json","../src/version.ts"],"sourcesContent":["import { basename } from \"node:path\";\n\nimport { resolveInvocationProfileName } from \"@tinycloud/operations/profile\";\n\nimport { serveTinyCloudMcp, MCP_VERSION } from \"./server.js\";\n\nexport interface ParsedCliOptions {\n readonly profile?: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n readonly help: boolean;\n readonly version: boolean;\n}\n\nconst HELP = `TinyCloud delegated operations MCP server\n\nUsage: tinycloud-mcp [options]\n\nOptions:\n --profile <name> Pin the TinyCloud profile for this process\n --allow-owner-profile Allow data execution for an explicitly selected owner profile\n --help Show this help\n --version Show the package version\n`;\n\nexport function parseCliOptions(arguments_: readonly string[]): ParsedCliOptions {\n let profile: string | undefined;\n let explicitProfile = false;\n let allowOwnerProfile = false;\n let help = false;\n let version = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === \"--help\" || argument === \"-h\") {\n help = true;\n continue;\n }\n if (argument === \"--version\" || argument === \"-v\") {\n version = true;\n continue;\n }\n if (argument === \"--allow-owner-profile\") {\n allowOwnerProfile = true;\n continue;\n }\n if (argument === \"--profile\") {\n const value = arguments_[index + 1];\n if (value === undefined || value.startsWith(\"-\") || value.trim().length === 0) {\n throw new Error(\"--profile requires a non-empty profile name.\");\n }\n profile = value;\n explicitProfile = true;\n index += 1;\n continue;\n }\n if (argument?.startsWith(\"--profile=\")) {\n const value = argument.slice(\"--profile=\".length);\n if (value.trim().length === 0) throw new Error(\"--profile requires a non-empty profile name.\");\n profile = value;\n explicitProfile = true;\n continue;\n }\n throw new Error(`Unknown option: ${argument}`);\n }\n\n return { profile, explicitProfile, allowOwnerProfile, help, version };\n}\n\nexport async function main(arguments_: readonly string[] = process.argv.slice(2)): Promise<number> {\n let options: ParsedCliOptions;\n try {\n options = parseCliOptions(arguments_);\n } catch (error) {\n process.stderr.write(\"[tinycloud-mcp] Invalid command line.\\n\");\n return 2;\n }\n\n if (options.help) {\n process.stdout.write(HELP);\n return 0;\n }\n if (options.version) {\n process.stdout.write(`${MCP_VERSION}\\n`);\n return 0;\n }\n\n let profile: string;\n try {\n profile = await resolveInvocationProfileName(options.profile);\n } catch {\n process.stderr.write(\"[tinycloud-mcp] Could not select a profile.\\n\");\n return 2;\n }\n\n // The selected profile is now a value captured by the server closure. Every\n // operation receives it explicitly and cannot re-read TC_PROFILE/config.\n serveTinyCloudMcp({\n profile,\n explicitProfile: options.explicitProfile,\n allowOwnerProfile: options.allowOwnerProfile,\n });\n return 0;\n}\n\nfunction isDirectInvocation(): boolean {\n const argv = process.argv[1];\n if (argv === undefined) return false;\n return basename(argv) === \"cli.js\" || basename(argv) === \"cli.cjs\" || basename(argv) === \"tinycloud-mcp\";\n}\n\nif (isDirectInvocation()) {\n void main().then((code) => {\n if (code !== 0) process.exitCode = code;\n }).catch(() => {\n process.stderr.write(\"[tinycloud-mcp] Startup failed.\\n\");\n process.exitCode = 1;\n });\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { serveStdio, type StdioServerHandle } from \"@modelcontextprotocol/server/stdio\";\n\nimport { createJsonSchemaValidator, registerTinyCloudTools, type McpStartupSelection } from \"./tools.js\";\nimport { MCP_VERSION } from \"./version.js\";\n\nexport const MCP_SERVER_NAME = \"tinycloud-mcp\";\nexport { MCP_VERSION } from \"./version.js\";\nexport function createTinyCloudMcpServer(selection: McpStartupSelection): McpServer {\n const validator = createJsonSchemaValidator();\n const server = new McpServer(\n { name: MCP_SERVER_NAME, version: MCP_VERSION },\n { jsonSchemaValidator: validator },\n );\n registerTinyCloudTools(server, selection, validator);\n return server;\n}\n\n/** Start the only supported MCP transport: local stdio. */\nexport function serveTinyCloudMcp(selection: McpStartupSelection): StdioServerHandle {\n return serveStdio(\n () => createTinyCloudMcpServer(selection),\n { onerror: () => writeBoundedDiagnostic(\"MCP transport error\") },\n );\n}\n\nfunction writeBoundedDiagnostic(message: string): void {\n process.stderr.write(`[tinycloud-mcp] ${message}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { fromJsonSchema, type McpServer, type ToolAnnotations } from \"@modelcontextprotocol/server\";\nimport { addFormats, Ajv, AjvJsonSchemaValidator } from \"@modelcontextprotocol/server/validators/ajv\";\nimport { invokeOperation } from \"@tinycloud/operations\";\n\nimport { toMcpToolResult, type McpToolResult } from \"./results.js\";\n\nexport const TOOL_NAMES = [\n \"tinycloud_status\",\n \"tinycloud_auth_status\",\n \"tinycloud_auth_capabilities\",\n \"tinycloud_auth_request\",\n \"tinycloud_auth_import\",\n \"tinycloud_account_spaces_list\",\n \"tinycloud_account_applications_list\",\n \"tinycloud_kv_list\",\n \"tinycloud_kv_get\",\n \"tinycloud_secrets_get\",\n] as const;\n\nexport type ToolName = (typeof TOOL_NAMES)[number];\n\nexport interface McpStartupSelection {\n readonly profile: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n}\n\nexport interface McpInvocationTarget {\n readonly profile: string;\n readonly allowOwnerProfile?: true;\n}\n\n/** Project one startup selection into the only owner-sensitive target shape. */\nexport function invocationTargetForMcp(\n selection: McpStartupSelection,\n): McpInvocationTarget {\n return {\n profile: selection.profile,\n ...(selection.explicitProfile && selection.allowOwnerProfile\n ? { allowOwnerProfile: true }\n : {}),\n };\n}\n\ninterface CatalogOperation {\n readonly id: string;\n readonly version: number;\n readonly title: string;\n readonly description: string;\n readonly input: Record<string, unknown>;\n readonly result: Record<string, unknown>;\n}\n\ninterface OperationsCatalog {\n readonly operations: readonly CatalogOperation[];\n}\n\n// The require anchor is this module, never the consumer entrypoint. In ESM\n// tsup preserves import.meta.url; in CJS it rewrites the same module-relative\n// anchor to the generated __filename, so both formats stay in MCP's package\n// dependency boundary.\nconst packageRequire = createRequire(\n typeof __dirname === \"string\" ? join(__dirname, \"tools.cjs\") : import.meta.url,\n);\nconst generatedCatalog = packageRequire(\n \"@tinycloud/operations/operations.json\",\n) as OperationsCatalog;\n\ninterface ToolBinding {\n readonly name: ToolName;\n readonly operationId: string;\n readonly operationVersion: number;\n readonly readOnlyHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n}\n\nconst TOOL_BINDINGS: readonly ToolBinding[] = [\n {\n name: \"tinycloud_status\",\n operationId: \"tinycloud.status.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_status\",\n operationId: \"tinycloud.auth.status\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_capabilities\",\n operationId: \"tinycloud.auth.capabilities\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_request\",\n operationId: \"tinycloud.auth.request\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_import\",\n operationId: \"tinycloud.auth.import\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_account_spaces_list\",\n operationId: \"tinycloud.account.spaces.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_account_applications_list\",\n operationId: \"tinycloud.account.applications.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_list\",\n operationId: \"tinycloud.kv.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_get\",\n operationId: \"tinycloud.kv.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_secrets_get\",\n operationId: \"tinycloud.secrets.get\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: true,\n },\n] as const;\n\nexport function createJsonSchemaValidator(): AjvJsonSchemaValidator {\n const ajv = new Ajv({ strict: false });\n addFormats(ajv);\n return new AjvJsonSchemaValidator(ajv);\n}\n\nexport function registerTinyCloudTools(\n server: McpServer,\n selection: McpStartupSelection,\n validator: AjvJsonSchemaValidator,\n): void {\n const definitions = new Map(\n generatedCatalog.operations.map((operation) => [\n `${operation.id}@${operation.version}`,\n operation,\n ]),\n );\n\n for (const binding of TOOL_BINDINGS) {\n const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);\n if (operation === undefined) {\n throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);\n }\n\n const inputSchema = fromJsonSchema(\n operation.input as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const outputSchema = fromJsonSchema(\n operation.result as unknown as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const annotations: ToolAnnotations = {\n readOnlyHint: binding.readOnlyHint,\n idempotentHint: binding.idempotentHint,\n destructiveHint: false,\n openWorldHint: binding.openWorldHint,\n };\n\n server.registerTool(\n binding.name,\n {\n title: operation.title,\n description: operation.description,\n inputSchema,\n outputSchema,\n annotations,\n },\n async (input: unknown): Promise<McpToolResult> => {\n const result = await invokeOperation(\n binding.operationId,\n binding.operationVersion,\n invocationTargetForMcp(selection),\n input,\n );\n return toMcpToolResult(result);\n },\n );\n }\n}\n\nexport function toolBindingsForTest(): readonly ToolBinding[] {\n return TOOL_BINDINGS;\n}\n","/**\n * MCP has one structured result channel for a TinyCloud operation. Text is a\n * fixed, non-sensitive status line; it never serializes the operation result.\n */\nexport interface CanonicalOperationResult {\n readonly status: \"ok\" | \"authority_required\" | \"setup_required\" | \"error\";\n readonly [key: string]: unknown;\n}\n\nexport interface McpToolResult extends CallToolResult {\n readonly content: [{ readonly type: \"text\"; readonly text: string }];\n readonly structuredContent: CanonicalOperationResult;\n}\n\nexport function toMcpToolResult(result: unknown): McpToolResult {\n const canonical: CanonicalOperationResult = isCanonicalOperationResult(result)\n ? result\n : {\n status: \"error\",\n operation: {},\n context: {},\n error: { code: \"INTERNAL_ERROR\" },\n };\n\n return {\n content: [{ type: \"text\", text: resultSummary(canonical.status) }],\n structuredContent: canonical,\n };\n}\n\n/** The canonical envelope immediately before MCP protocol serialization. */\nexport function canonicalMcpAdapterResult(result: unknown): CanonicalOperationResult {\n return toMcpToolResult(result).structuredContent;\n}\n\nfunction isCanonicalOperationResult(value: unknown): value is CanonicalOperationResult {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const status = (value as { status?: unknown }).status;\n return status === \"ok\" ||\n status === \"authority_required\" ||\n status === \"setup_required\" ||\n status === \"error\";\n}\n\nfunction resultSummary(status: CanonicalOperationResult[\"status\"]): string {\n switch (status) {\n case \"ok\":\n return \"TinyCloud operation completed; use the structured result.\";\n case \"authority_required\":\n return \"TinyCloud authority is required; use the structured request and approval action.\";\n case \"setup_required\":\n return \"TinyCloud setup is required; use the structured setup action.\";\n case \"error\":\n return \"TinyCloud operation failed; use the structured error.\";\n }\n}\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n","{\n \"name\": \"@tinycloud/mcp\",\n \"version\": \"0.1.0\",\n \"description\": \"TinyCloud delegated operations MCP server\",\n \"author\": \"TinyCloud, Inc.\",\n \"license\": \"EGPL\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"tinycloud-mcp\": \"./bin/tinycloud-mcp\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"types\": \"./dist/server.d.ts\",\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./tools\": {\n \"types\": \"./dist/tools.d.ts\",\n \"import\": \"./dist/tools.js\",\n \"require\": \"./dist/tools.cjs\"\n },\n \"./results\": {\n \"types\": \"./dist/results.d.ts\",\n \"import\": \"./dist/results.js\",\n \"require\": \"./dist/results.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"generated\",\n \"skills\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"bun run build && bun scripts/test.ts && bun run check:generated\",\n \"test:stdio\": \"bun run build && bun test src/stdio.test.ts\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"generate\": \"bun scripts/generate.ts\",\n \"check:generated\": \"bun scripts/generate.ts --check\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/server\": \"2.0.0-beta.4\",\n \"@tinycloud/operations\": \"0.1.0\"\n },\n \"devDependencies\": {\n \"@modelcontextprotocol/client\": \"2.0.0-beta.4\",\n \"@types/node\": \"^20\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/tinycloudlabs/web-sdk\"\n }\n}\n","import packageMetadata from \"../package.json\";\n\nexport const MCP_VERSION = packageMetadata.version;\n"],"mappings":";AAAA,SAAS,gBAAgB;AAEzB,SAAS,oCAAoC;;;ACF7C,SAAS,iBAAiB;AAC1B,SAAS,kBAA0C;;;ACDnD,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AAErB,SAAS,sBAA4D;AACrE,SAAS,YAAY,KAAK,8BAA8B;AACxD,SAAS,uBAAuB;;;ACSzB,SAAS,gBAAgB,QAAgC;AAC9D,QAAM,YAAsC,2BAA2B,MAAM,IACzE,SACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW,CAAC;AAAA,IACZ,SAAS,CAAC;AAAA,IACV,OAAO,EAAE,MAAM,iBAAiB;AAAA,EAClC;AAEF,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,cAAc,UAAU,MAAM,EAAE,CAAC;AAAA,IACjE,mBAAmB;AAAA,EACrB;AACF;AAOA,SAAS,2BAA2B,OAAmD;AACrF,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,SAAU,MAA+B;AAC/C,SAAO,WAAW,QAChB,WAAW,wBACX,WAAW,oBACX,WAAW;AACf;AAEA,SAAS,cAAc,QAAoD;AACzE,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;A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,MAAM,aAAa,SAAS,IAAI,MAAM;AAC3F;AAEA,IAAI,mBAAmB,GAAG;AACxB,OAAK,KAAK,EAAE,KAAK,CAAC,SAAS;AACzB,QAAI,SAAS,EAAG,SAAQ,WAAW;AAAA,EACrC,CAAC,EAAE,MAAM,MAAM;AACb,YAAQ,OAAO,MAAM,mCAAmC;AACxD,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -246,7 +246,7 @@ function registerTinyCloudTools(server, selection, validator) {
|
|
|
246
246
|
// package.json
|
|
247
247
|
var package_default = {
|
|
248
248
|
name: "@tinycloud/mcp",
|
|
249
|
-
version: "0.1.0
|
|
249
|
+
version: "0.1.0",
|
|
250
250
|
description: "TinyCloud delegated operations MCP server",
|
|
251
251
|
author: "TinyCloud, Inc.",
|
|
252
252
|
license: "EGPL",
|
|
@@ -299,7 +299,7 @@ var package_default = {
|
|
|
299
299
|
},
|
|
300
300
|
dependencies: {
|
|
301
301
|
"@modelcontextprotocol/server": "2.0.0-beta.4",
|
|
302
|
-
"@tinycloud/operations": "0.1.0
|
|
302
|
+
"@tinycloud/operations": "0.1.0"
|
|
303
303
|
},
|
|
304
304
|
devDependencies: {
|
|
305
305
|
"@modelcontextprotocol/client": "2.0.0-beta.4",
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/cli.ts","../src/server.ts","../src/tools.ts","../src/results.ts","../package.json","../src/version.ts"],"sourcesContent":["export { main, parseCliOptions } from \"./cli.js\";\nexport { createTinyCloudMcpServer, serveTinyCloudMcp, MCP_SERVER_NAME, MCP_VERSION } from \"./server.js\";\nexport { registerTinyCloudTools, TOOL_NAMES } from \"./tools.js\";\nexport { canonicalMcpAdapterResult, toMcpToolResult } from \"./results.js\";\n","import { basename } from \"node:path\";\n\nimport { resolveInvocationProfileName } from \"@tinycloud/operations/profile\";\n\nimport { serveTinyCloudMcp, MCP_VERSION } from \"./server.js\";\n\nexport interface ParsedCliOptions {\n readonly profile?: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n readonly help: boolean;\n readonly version: boolean;\n}\n\nconst HELP = `TinyCloud delegated operations MCP server\n\nUsage: tinycloud-mcp [options]\n\nOptions:\n --profile <name> Pin the TinyCloud profile for this process\n --allow-owner-profile Allow data execution for an explicitly selected owner profile\n --help Show this help\n --version Show the package version\n`;\n\nexport function parseCliOptions(arguments_: readonly string[]): ParsedCliOptions {\n let profile: string | undefined;\n let explicitProfile = false;\n let allowOwnerProfile = false;\n let help = false;\n let version = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === \"--help\" || argument === \"-h\") {\n help = true;\n continue;\n }\n if (argument === \"--version\" || argument === \"-v\") {\n version = true;\n continue;\n }\n if (argument === \"--allow-owner-profile\") {\n allowOwnerProfile = true;\n continue;\n }\n if (argument === \"--profile\") {\n const value = arguments_[index + 1];\n if (value === undefined || value.startsWith(\"-\") || value.trim().length === 0) {\n throw new Error(\"--profile requires a non-empty profile name.\");\n }\n profile = value;\n explicitProfile = true;\n index += 1;\n continue;\n }\n if (argument?.startsWith(\"--profile=\")) {\n const value = argument.slice(\"--profile=\".length);\n if (value.trim().length === 0) throw new Error(\"--profile requires a non-empty profile name.\");\n profile = value;\n explicitProfile = true;\n continue;\n }\n throw new Error(`Unknown option: ${argument}`);\n }\n\n return { profile, explicitProfile, allowOwnerProfile, help, version };\n}\n\nexport async function main(arguments_: readonly string[] = process.argv.slice(2)): Promise<number> {\n let options: ParsedCliOptions;\n try {\n options = parseCliOptions(arguments_);\n } catch (error) {\n process.stderr.write(\"[tinycloud-mcp] Invalid command line.\\n\");\n return 2;\n }\n\n if (options.help) {\n process.stdout.write(HELP);\n return 0;\n }\n if (options.version) {\n process.stdout.write(`${MCP_VERSION}\\n`);\n return 0;\n }\n\n let profile: string;\n try {\n profile = await resolveInvocationProfileName(options.profile);\n } catch {\n process.stderr.write(\"[tinycloud-mcp] Could not select a profile.\\n\");\n return 2;\n }\n\n // The selected profile is now a value captured by the server closure. Every\n // operation receives it explicitly and cannot re-read TC_PROFILE/config.\n serveTinyCloudMcp({\n profile,\n explicitProfile: options.explicitProfile,\n allowOwnerProfile: options.allowOwnerProfile,\n });\n return 0;\n}\n\nfunction isDirectInvocation(): boolean {\n const argv = process.argv[1];\n if (argv === undefined) return false;\n return basename(argv) === \"cli.js\" || basename(argv) === \"cli.cjs\" || basename(argv) === \"tinycloud-mcp\";\n}\n\nif (isDirectInvocation()) {\n void main().then((code) => {\n if (code !== 0) process.exitCode = code;\n }).catch(() => {\n process.stderr.write(\"[tinycloud-mcp] Startup failed.\\n\");\n process.exitCode = 1;\n });\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { serveStdio, type StdioServerHandle } from \"@modelcontextprotocol/server/stdio\";\n\nimport { createJsonSchemaValidator, registerTinyCloudTools, type McpStartupSelection } from \"./tools.js\";\nimport { MCP_VERSION } from \"./version.js\";\n\nexport const MCP_SERVER_NAME = \"tinycloud-mcp\";\nexport { MCP_VERSION } from \"./version.js\";\nexport function createTinyCloudMcpServer(selection: McpStartupSelection): McpServer {\n const validator = createJsonSchemaValidator();\n const server = new McpServer(\n { name: MCP_SERVER_NAME, version: MCP_VERSION },\n { jsonSchemaValidator: validator },\n );\n registerTinyCloudTools(server, selection, validator);\n return server;\n}\n\n/** Start the only supported MCP transport: local stdio. */\nexport function serveTinyCloudMcp(selection: McpStartupSelection): StdioServerHandle {\n return serveStdio(\n () => createTinyCloudMcpServer(selection),\n { onerror: () => writeBoundedDiagnostic(\"MCP transport error\") },\n );\n}\n\nfunction writeBoundedDiagnostic(message: string): void {\n process.stderr.write(`[tinycloud-mcp] ${message}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { fromJsonSchema, type McpServer, type ToolAnnotations } from \"@modelcontextprotocol/server\";\nimport { addFormats, Ajv, AjvJsonSchemaValidator } from \"@modelcontextprotocol/server/validators/ajv\";\nimport { invokeOperation } from \"@tinycloud/operations\";\n\nimport { toMcpToolResult, type McpToolResult } from \"./results.js\";\n\nexport const TOOL_NAMES = [\n \"tinycloud_status\",\n \"tinycloud_auth_status\",\n \"tinycloud_auth_capabilities\",\n \"tinycloud_auth_request\",\n \"tinycloud_auth_import\",\n \"tinycloud_account_spaces_list\",\n \"tinycloud_account_applications_list\",\n \"tinycloud_kv_list\",\n \"tinycloud_kv_get\",\n \"tinycloud_secrets_get\",\n] as const;\n\nexport type ToolName = (typeof TOOL_NAMES)[number];\n\nexport interface McpStartupSelection {\n readonly profile: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n}\n\nexport interface McpInvocationTarget {\n readonly profile: string;\n readonly allowOwnerProfile?: true;\n}\n\n/** Project one startup selection into the only owner-sensitive target shape. */\nexport function invocationTargetForMcp(\n selection: McpStartupSelection,\n): McpInvocationTarget {\n return {\n profile: selection.profile,\n ...(selection.explicitProfile && selection.allowOwnerProfile\n ? { allowOwnerProfile: true }\n : {}),\n };\n}\n\ninterface CatalogOperation {\n readonly id: string;\n readonly version: number;\n readonly title: string;\n readonly description: string;\n readonly input: Record<string, unknown>;\n readonly result: Record<string, unknown>;\n}\n\ninterface OperationsCatalog {\n readonly operations: readonly CatalogOperation[];\n}\n\n// The require anchor is this module, never the consumer entrypoint. In ESM\n// tsup preserves import.meta.url; in CJS it rewrites the same module-relative\n// anchor to the generated __filename, so both formats stay in MCP's package\n// dependency boundary.\nconst packageRequire = createRequire(\n typeof __dirname === \"string\" ? join(__dirname, \"tools.cjs\") : import.meta.url,\n);\nconst generatedCatalog = packageRequire(\n \"@tinycloud/operations/operations.json\",\n) as OperationsCatalog;\n\ninterface ToolBinding {\n readonly name: ToolName;\n readonly operationId: string;\n readonly operationVersion: number;\n readonly readOnlyHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n}\n\nconst TOOL_BINDINGS: readonly ToolBinding[] = [\n {\n name: \"tinycloud_status\",\n operationId: \"tinycloud.status.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_status\",\n operationId: \"tinycloud.auth.status\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_capabilities\",\n operationId: \"tinycloud.auth.capabilities\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_request\",\n operationId: \"tinycloud.auth.request\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_import\",\n operationId: \"tinycloud.auth.import\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_account_spaces_list\",\n operationId: \"tinycloud.account.spaces.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_account_applications_list\",\n operationId: \"tinycloud.account.applications.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_list\",\n operationId: \"tinycloud.kv.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_get\",\n operationId: \"tinycloud.kv.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_secrets_get\",\n operationId: \"tinycloud.secrets.get\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: true,\n },\n] as const;\n\nexport function createJsonSchemaValidator(): AjvJsonSchemaValidator {\n const ajv = new Ajv({ strict: false });\n addFormats(ajv);\n return new AjvJsonSchemaValidator(ajv);\n}\n\nexport function registerTinyCloudTools(\n server: McpServer,\n selection: McpStartupSelection,\n validator: AjvJsonSchemaValidator,\n): void {\n const definitions = new Map(\n generatedCatalog.operations.map((operation) => [\n `${operation.id}@${operation.version}`,\n operation,\n ]),\n );\n\n for (const binding of TOOL_BINDINGS) {\n const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);\n if (operation === undefined) {\n throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);\n }\n\n const inputSchema = fromJsonSchema(\n operation.input as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const outputSchema = fromJsonSchema(\n operation.result as unknown as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const annotations: ToolAnnotations = {\n readOnlyHint: binding.readOnlyHint,\n idempotentHint: binding.idempotentHint,\n destructiveHint: false,\n openWorldHint: binding.openWorldHint,\n };\n\n server.registerTool(\n binding.name,\n {\n title: operation.title,\n description: operation.description,\n inputSchema,\n outputSchema,\n annotations,\n },\n async (input: unknown): Promise<McpToolResult> => {\n const result = await invokeOperation(\n binding.operationId,\n binding.operationVersion,\n invocationTargetForMcp(selection),\n input,\n );\n return toMcpToolResult(result);\n },\n );\n }\n}\n\nexport function toolBindingsForTest(): readonly ToolBinding[] {\n return TOOL_BINDINGS;\n}\n","/**\n * MCP has one structured result channel for a TinyCloud operation. Text is a\n * fixed, non-sensitive status line; it never serializes the operation result.\n */\nexport interface CanonicalOperationResult {\n readonly status: \"ok\" | \"authority_required\" | \"setup_required\" | \"error\";\n readonly [key: string]: unknown;\n}\n\nexport interface McpToolResult extends CallToolResult {\n readonly content: [{ readonly type: \"text\"; readonly text: string }];\n readonly structuredContent: CanonicalOperationResult;\n}\n\nexport function toMcpToolResult(result: unknown): McpToolResult {\n const canonical: CanonicalOperationResult = isCanonicalOperationResult(result)\n ? result\n : {\n status: \"error\",\n operation: {},\n context: {},\n error: { code: \"INTERNAL_ERROR\" },\n };\n\n return {\n content: [{ type: \"text\", text: resultSummary(canonical.status) }],\n structuredContent: canonical,\n };\n}\n\n/** The canonical envelope immediately before MCP protocol serialization. */\nexport function canonicalMcpAdapterResult(result: unknown): CanonicalOperationResult {\n return toMcpToolResult(result).structuredContent;\n}\n\nfunction isCanonicalOperationResult(value: unknown): value is CanonicalOperationResult {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const status = (value as { status?: unknown }).status;\n return status === \"ok\" ||\n status === \"authority_required\" ||\n status === \"setup_required\" ||\n status === \"error\";\n}\n\nfunction resultSummary(status: CanonicalOperationResult[\"status\"]): string {\n switch (status) {\n case \"ok\":\n return \"TinyCloud operation completed; use the structured result.\";\n case \"authority_required\":\n return \"TinyCloud authority is required; use the structured request and approval action.\";\n case \"setup_required\":\n return \"TinyCloud setup is required; use the structured setup action.\";\n case \"error\":\n return \"TinyCloud operation failed; use the structured error.\";\n }\n}\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n","{\n \"name\": \"@tinycloud/mcp\",\n \"version\": \"0.1.0-beta.2\",\n \"description\": \"TinyCloud delegated operations MCP server\",\n \"author\": \"TinyCloud, Inc.\",\n \"license\": \"EGPL\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"tinycloud-mcp\": \"./bin/tinycloud-mcp\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"types\": \"./dist/server.d.ts\",\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./tools\": {\n \"types\": \"./dist/tools.d.ts\",\n \"import\": \"./dist/tools.js\",\n \"require\": \"./dist/tools.cjs\"\n },\n \"./results\": {\n \"types\": \"./dist/results.d.ts\",\n \"import\": \"./dist/results.js\",\n \"require\": \"./dist/results.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"generated\",\n \"skills\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"bun run build && bun scripts/test.ts && bun run check:generated\",\n \"test:stdio\": \"bun run build && bun test src/stdio.test.ts\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"generate\": \"bun scripts/generate.ts\",\n \"check:generated\": \"bun scripts/generate.ts --check\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/server\": \"2.0.0-beta.4\",\n \"@tinycloud/operations\": \"0.1.0-beta.2\"\n },\n \"devDependencies\": {\n \"@modelcontextprotocol/client\": \"2.0.0-beta.4\",\n \"@types/node\": \"^20\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/tinycloudlabs/web-sdk\"\n }\n}\n","import packageMetadata from \"../package.json\";\n\nexport const MCP_VERSION = packageMetadata.version;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,oBAAyB;AAEzB,qBAA6C;;;ACF7C,IAAAC,iBAA0B;AAC1B,mBAAmD;;;ACDnD,yBAA8B;AAC9B,uBAAqB;AAErB,oBAAqE;AACrE,iBAAwD;AACxD,wBAAgC;;;ACSzB,SAAS,gBAAgB,QAAgC;AAC9D,QAAM,YAAsC,2BAA2B,MAAM,IACzE,SACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW,CAAC;AAAA,IACZ,SAAS,CAAC;AAAA,IACV,OAAO,EAAE,MAAM,iBAAiB;AAAA,EAClC;AAEF,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,cAAc,UAAU,MAAM,EAAE,CAAC;AAAA,IACjE,mBAAmB;AAAA,EACrB;AACF;AAGO,SAAS,0BAA0B,QAA2C;AACnF,SAAO,gBAAgB,MAAM,EAAE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ACvC,WAAO;AAAA,EACT;AAEA,MAAI;AACJ,MAAI;AACF,cAAU,UAAM,6CAA6B,QAAQ,OAAO;AAAA,EAC9D,QAAQ;AACN,YAAQ,OAAO,MAAM,+CAA+C;AACpE,WAAO;AAAA,EACT;AAIA,oBAAkB;AAAA,IAChB;AAAA,IACA,iBAAiB,QAAQ;AAAA,IACzB,mBAAmB,QAAQ;AAAA,EAC7B,CAAC;AACD,SAAO;AACT;AAEA,SAAS,qBAA8B;AACrC,QAAM,OAAO,QAAQ,KAAK,CAAC;AAC3B,MAAI,SAAS,OAAW,QAAO;AAC/B,aAAO,4BAAS,IAAI,MAAM,gBAAY,4BAAS,IAAI,MAAM,iBAAa,4BAAS,IAAI,MAAM;AAC3F;AAEA,IAAI,mBAAmB,GAAG;AACxB,OAAK,KAAK,EAAE,KAAK,CAAC,SAAS;AACzB,QAAI,SAAS,EAAG,SAAQ,WAAW;AAAA,EACrC,CAAC,EAAE,MAAM,MAAM;AACb,YAAQ,OAAO,MAAM,mCAAmC;AACxD,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":["import_node_path","import_server"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/cli.ts","../src/server.ts","../src/tools.ts","../src/results.ts","../package.json","../src/version.ts"],"sourcesContent":["export { main, parseCliOptions } from \"./cli.js\";\nexport { createTinyCloudMcpServer, serveTinyCloudMcp, MCP_SERVER_NAME, MCP_VERSION } from \"./server.js\";\nexport { registerTinyCloudTools, TOOL_NAMES } from \"./tools.js\";\nexport { canonicalMcpAdapterResult, toMcpToolResult } from \"./results.js\";\n","import { basename } from \"node:path\";\n\nimport { resolveInvocationProfileName } from \"@tinycloud/operations/profile\";\n\nimport { serveTinyCloudMcp, MCP_VERSION } from \"./server.js\";\n\nexport interface ParsedCliOptions {\n readonly profile?: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n readonly help: boolean;\n readonly version: boolean;\n}\n\nconst HELP = `TinyCloud delegated operations MCP server\n\nUsage: tinycloud-mcp [options]\n\nOptions:\n --profile <name> Pin the TinyCloud profile for this process\n --allow-owner-profile Allow data execution for an explicitly selected owner profile\n --help Show this help\n --version Show the package version\n`;\n\nexport function parseCliOptions(arguments_: readonly string[]): ParsedCliOptions {\n let profile: string | undefined;\n let explicitProfile = false;\n let allowOwnerProfile = false;\n let help = false;\n let version = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === \"--help\" || argument === \"-h\") {\n help = true;\n continue;\n }\n if (argument === \"--version\" || argument === \"-v\") {\n version = true;\n continue;\n }\n if (argument === \"--allow-owner-profile\") {\n allowOwnerProfile = true;\n continue;\n }\n if (argument === \"--profile\") {\n const value = arguments_[index + 1];\n if (value === undefined || value.startsWith(\"-\") || value.trim().length === 0) {\n throw new Error(\"--profile requires a non-empty profile name.\");\n }\n profile = value;\n explicitProfile = true;\n index += 1;\n continue;\n }\n if (argument?.startsWith(\"--profile=\")) {\n const value = argument.slice(\"--profile=\".length);\n if (value.trim().length === 0) throw new Error(\"--profile requires a non-empty profile name.\");\n profile = value;\n explicitProfile = true;\n continue;\n }\n throw new Error(`Unknown option: ${argument}`);\n }\n\n return { profile, explicitProfile, allowOwnerProfile, help, version };\n}\n\nexport async function main(arguments_: readonly string[] = process.argv.slice(2)): Promise<number> {\n let options: ParsedCliOptions;\n try {\n options = parseCliOptions(arguments_);\n } catch (error) {\n process.stderr.write(\"[tinycloud-mcp] Invalid command line.\\n\");\n return 2;\n }\n\n if (options.help) {\n process.stdout.write(HELP);\n return 0;\n }\n if (options.version) {\n process.stdout.write(`${MCP_VERSION}\\n`);\n return 0;\n }\n\n let profile: string;\n try {\n profile = await resolveInvocationProfileName(options.profile);\n } catch {\n process.stderr.write(\"[tinycloud-mcp] Could not select a profile.\\n\");\n return 2;\n }\n\n // The selected profile is now a value captured by the server closure. Every\n // operation receives it explicitly and cannot re-read TC_PROFILE/config.\n serveTinyCloudMcp({\n profile,\n explicitProfile: options.explicitProfile,\n allowOwnerProfile: options.allowOwnerProfile,\n });\n return 0;\n}\n\nfunction isDirectInvocation(): boolean {\n const argv = process.argv[1];\n if (argv === undefined) return false;\n return basename(argv) === \"cli.js\" || basename(argv) === \"cli.cjs\" || basename(argv) === \"tinycloud-mcp\";\n}\n\nif (isDirectInvocation()) {\n void main().then((code) => {\n if (code !== 0) process.exitCode = code;\n }).catch(() => {\n process.stderr.write(\"[tinycloud-mcp] Startup failed.\\n\");\n process.exitCode = 1;\n });\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { serveStdio, type StdioServerHandle } from \"@modelcontextprotocol/server/stdio\";\n\nimport { createJsonSchemaValidator, registerTinyCloudTools, type McpStartupSelection } from \"./tools.js\";\nimport { MCP_VERSION } from \"./version.js\";\n\nexport const MCP_SERVER_NAME = \"tinycloud-mcp\";\nexport { MCP_VERSION } from \"./version.js\";\nexport function createTinyCloudMcpServer(selection: McpStartupSelection): McpServer {\n const validator = createJsonSchemaValidator();\n const server = new McpServer(\n { name: MCP_SERVER_NAME, version: MCP_VERSION },\n { jsonSchemaValidator: validator },\n );\n registerTinyCloudTools(server, selection, validator);\n return server;\n}\n\n/** Start the only supported MCP transport: local stdio. */\nexport function serveTinyCloudMcp(selection: McpStartupSelection): StdioServerHandle {\n return serveStdio(\n () => createTinyCloudMcpServer(selection),\n { onerror: () => writeBoundedDiagnostic(\"MCP transport error\") },\n );\n}\n\nfunction writeBoundedDiagnostic(message: string): void {\n process.stderr.write(`[tinycloud-mcp] ${message}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { fromJsonSchema, type McpServer, type ToolAnnotations } from \"@modelcontextprotocol/server\";\nimport { addFormats, Ajv, AjvJsonSchemaValidator } from \"@modelcontextprotocol/server/validators/ajv\";\nimport { invokeOperation } from \"@tinycloud/operations\";\n\nimport { toMcpToolResult, type McpToolResult } from \"./results.js\";\n\nexport const TOOL_NAMES = [\n \"tinycloud_status\",\n \"tinycloud_auth_status\",\n \"tinycloud_auth_capabilities\",\n \"tinycloud_auth_request\",\n \"tinycloud_auth_import\",\n \"tinycloud_account_spaces_list\",\n \"tinycloud_account_applications_list\",\n \"tinycloud_kv_list\",\n \"tinycloud_kv_get\",\n \"tinycloud_secrets_get\",\n] as const;\n\nexport type ToolName = (typeof TOOL_NAMES)[number];\n\nexport interface McpStartupSelection {\n readonly profile: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n}\n\nexport interface McpInvocationTarget {\n readonly profile: string;\n readonly allowOwnerProfile?: true;\n}\n\n/** Project one startup selection into the only owner-sensitive target shape. */\nexport function invocationTargetForMcp(\n selection: McpStartupSelection,\n): McpInvocationTarget {\n return {\n profile: selection.profile,\n ...(selection.explicitProfile && selection.allowOwnerProfile\n ? { allowOwnerProfile: true }\n : {}),\n };\n}\n\ninterface CatalogOperation {\n readonly id: string;\n readonly version: number;\n readonly title: string;\n readonly description: string;\n readonly input: Record<string, unknown>;\n readonly result: Record<string, unknown>;\n}\n\ninterface OperationsCatalog {\n readonly operations: readonly CatalogOperation[];\n}\n\n// The require anchor is this module, never the consumer entrypoint. In ESM\n// tsup preserves import.meta.url; in CJS it rewrites the same module-relative\n// anchor to the generated __filename, so both formats stay in MCP's package\n// dependency boundary.\nconst packageRequire = createRequire(\n typeof __dirname === \"string\" ? join(__dirname, \"tools.cjs\") : import.meta.url,\n);\nconst generatedCatalog = packageRequire(\n \"@tinycloud/operations/operations.json\",\n) as OperationsCatalog;\n\ninterface ToolBinding {\n readonly name: ToolName;\n readonly operationId: string;\n readonly operationVersion: number;\n readonly readOnlyHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n}\n\nconst TOOL_BINDINGS: readonly ToolBinding[] = [\n {\n name: \"tinycloud_status\",\n operationId: \"tinycloud.status.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_status\",\n operationId: \"tinycloud.auth.status\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_capabilities\",\n operationId: \"tinycloud.auth.capabilities\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_request\",\n operationId: \"tinycloud.auth.request\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_import\",\n operationId: \"tinycloud.auth.import\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_account_spaces_list\",\n operationId: \"tinycloud.account.spaces.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_account_applications_list\",\n operationId: \"tinycloud.account.applications.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_list\",\n operationId: \"tinycloud.kv.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_get\",\n operationId: \"tinycloud.kv.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_secrets_get\",\n operationId: \"tinycloud.secrets.get\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: true,\n },\n] as const;\n\nexport function createJsonSchemaValidator(): AjvJsonSchemaValidator {\n const ajv = new Ajv({ strict: false });\n addFormats(ajv);\n return new AjvJsonSchemaValidator(ajv);\n}\n\nexport function registerTinyCloudTools(\n server: McpServer,\n selection: McpStartupSelection,\n validator: AjvJsonSchemaValidator,\n): void {\n const definitions = new Map(\n generatedCatalog.operations.map((operation) => [\n `${operation.id}@${operation.version}`,\n operation,\n ]),\n );\n\n for (const binding of TOOL_BINDINGS) {\n const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);\n if (operation === undefined) {\n throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);\n }\n\n const inputSchema = fromJsonSchema(\n operation.input as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const outputSchema = fromJsonSchema(\n operation.result as unknown as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const annotations: ToolAnnotations = {\n readOnlyHint: binding.readOnlyHint,\n idempotentHint: binding.idempotentHint,\n destructiveHint: false,\n openWorldHint: binding.openWorldHint,\n };\n\n server.registerTool(\n binding.name,\n {\n title: operation.title,\n description: operation.description,\n inputSchema,\n outputSchema,\n annotations,\n },\n async (input: unknown): Promise<McpToolResult> => {\n const result = await invokeOperation(\n binding.operationId,\n binding.operationVersion,\n invocationTargetForMcp(selection),\n input,\n );\n return toMcpToolResult(result);\n },\n );\n }\n}\n\nexport function toolBindingsForTest(): readonly ToolBinding[] {\n return TOOL_BINDINGS;\n}\n","/**\n * MCP has one structured result channel for a TinyCloud operation. Text is a\n * fixed, non-sensitive status line; it never serializes the operation result.\n */\nexport interface CanonicalOperationResult {\n readonly status: \"ok\" | \"authority_required\" | \"setup_required\" | \"error\";\n readonly [key: string]: unknown;\n}\n\nexport interface McpToolResult extends CallToolResult {\n readonly content: [{ readonly type: \"text\"; readonly text: string }];\n readonly structuredContent: CanonicalOperationResult;\n}\n\nexport function toMcpToolResult(result: unknown): McpToolResult {\n const canonical: CanonicalOperationResult = isCanonicalOperationResult(result)\n ? result\n : {\n status: \"error\",\n operation: {},\n context: {},\n error: { code: \"INTERNAL_ERROR\" },\n };\n\n return {\n content: [{ type: \"text\", text: resultSummary(canonical.status) }],\n structuredContent: canonical,\n };\n}\n\n/** The canonical envelope immediately before MCP protocol serialization. */\nexport function canonicalMcpAdapterResult(result: unknown): CanonicalOperationResult {\n return toMcpToolResult(result).structuredContent;\n}\n\nfunction isCanonicalOperationResult(value: unknown): value is CanonicalOperationResult {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const status = (value as { status?: unknown }).status;\n return status === \"ok\" ||\n status === \"authority_required\" ||\n status === \"setup_required\" ||\n status === \"error\";\n}\n\nfunction resultSummary(status: CanonicalOperationResult[\"status\"]): string {\n switch (status) {\n case \"ok\":\n return \"TinyCloud operation completed; use the structured result.\";\n case \"authority_required\":\n return \"TinyCloud authority is required; use the structured request and approval action.\";\n case \"setup_required\":\n return \"TinyCloud setup is required; use the structured setup action.\";\n case \"error\":\n return \"TinyCloud operation failed; use the structured error.\";\n }\n}\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n","{\n \"name\": \"@tinycloud/mcp\",\n \"version\": \"0.1.0\",\n \"description\": \"TinyCloud delegated operations MCP server\",\n \"author\": \"TinyCloud, Inc.\",\n \"license\": \"EGPL\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"tinycloud-mcp\": \"./bin/tinycloud-mcp\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"types\": \"./dist/server.d.ts\",\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./tools\": {\n \"types\": \"./dist/tools.d.ts\",\n \"import\": \"./dist/tools.js\",\n \"require\": \"./dist/tools.cjs\"\n },\n \"./results\": {\n \"types\": \"./dist/results.d.ts\",\n \"import\": \"./dist/results.js\",\n \"require\": \"./dist/results.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"generated\",\n \"skills\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"bun run build && bun scripts/test.ts && bun run check:generated\",\n \"test:stdio\": \"bun run build && bun test src/stdio.test.ts\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"generate\": \"bun scripts/generate.ts\",\n \"check:generated\": \"bun scripts/generate.ts --check\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/server\": \"2.0.0-beta.4\",\n \"@tinycloud/operations\": \"0.1.0\"\n },\n \"devDependencies\": {\n \"@modelcontextprotocol/client\": \"2.0.0-beta.4\",\n \"@types/node\": \"^20\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/tinycloudlabs/web-sdk\"\n }\n}\n","import packageMetadata from \"../package.json\";\n\nexport const MCP_VERSION = packageMetadata.version;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,oBAAyB;AAEzB,qBAA6C;;;ACF7C,IAAAC,iBAA0B;AAC1B,mBAAmD;;;ACDnD,yBAA8B;AAC9B,uBAAqB;AAErB,oBAAqE;AACrE,iBAAwD;AACxD,wBAAgC;;;ACSzB,SAAS,gBAAgB,QAAgC;AAC9D,QAAM,YAAsC,2BAA2B,MAAM,IACzE,SACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW,CAAC;AAAA,IACZ,SAAS,CAAC;AAAA,IACV,OAAO,EAAE,MAAM,iBAAiB;AAAA,EAClC;AAEF,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,cAAc,UAAU,MAAM,EAAE,CAAC;AAAA,IACjE,mBAAmB;AAAA,EACrB;AACF;AAGO,SAAS,0BAA0B,QAA2C;AACnF,SAAO,gBAAgB,MAAM,EAAE;AACjC;AAEA,SAAS,2BAA2B,OAAmD;AACrF,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,SAAU,MAA+B;AAC/C,SAAO,WAAW,QAChB,WAAW,wB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AAkB;AAAA,IAChB;AAAA,IACA,iBAAiB,QAAQ;AAAA,IACzB,mBAAmB,QAAQ;AAAA,EAC7B,CAAC;AACD,SAAO;AACT;AAEA,SAAS,qBAA8B;AACrC,QAAM,OAAO,QAAQ,KAAK,CAAC;AAC3B,MAAI,SAAS,OAAW,QAAO;AAC/B,aAAO,4BAAS,IAAI,MAAM,gBAAY,4BAAS,IAAI,MAAM,iBAAa,4BAAS,IAAI,MAAM;AAC3F;AAEA,IAAI,mBAAmB,GAAG;AACxB,OAAK,KAAK,EAAE,KAAK,CAAC,SAAS;AACzB,QAAI,SAAS,EAAG,SAAQ,WAAW;AAAA,EACrC,CAAC,EAAE,MAAM,MAAM;AACb,YAAQ,OAAO,MAAM,mCAAmC;AACxD,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":["import_node_path","import_server"]}
|
package/dist/index.js
CHANGED
|
@@ -210,7 +210,7 @@ function registerTinyCloudTools(server, selection, validator) {
|
|
|
210
210
|
// package.json
|
|
211
211
|
var package_default = {
|
|
212
212
|
name: "@tinycloud/mcp",
|
|
213
|
-
version: "0.1.0
|
|
213
|
+
version: "0.1.0",
|
|
214
214
|
description: "TinyCloud delegated operations MCP server",
|
|
215
215
|
author: "TinyCloud, Inc.",
|
|
216
216
|
license: "EGPL",
|
|
@@ -263,7 +263,7 @@ var package_default = {
|
|
|
263
263
|
},
|
|
264
264
|
dependencies: {
|
|
265
265
|
"@modelcontextprotocol/server": "2.0.0-beta.4",
|
|
266
|
-
"@tinycloud/operations": "0.1.0
|
|
266
|
+
"@tinycloud/operations": "0.1.0"
|
|
267
267
|
},
|
|
268
268
|
devDependencies: {
|
|
269
269
|
"@modelcontextprotocol/client": "2.0.0-beta.4",
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/server.ts","../src/tools.ts","../src/results.ts","../package.json","../src/version.ts"],"sourcesContent":["import { basename } from \"node:path\";\n\nimport { resolveInvocationProfileName } from \"@tinycloud/operations/profile\";\n\nimport { serveTinyCloudMcp, MCP_VERSION } from \"./server.js\";\n\nexport interface ParsedCliOptions {\n readonly profile?: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n readonly help: boolean;\n readonly version: boolean;\n}\n\nconst HELP = `TinyCloud delegated operations MCP server\n\nUsage: tinycloud-mcp [options]\n\nOptions:\n --profile <name> Pin the TinyCloud profile for this process\n --allow-owner-profile Allow data execution for an explicitly selected owner profile\n --help Show this help\n --version Show the package version\n`;\n\nexport function parseCliOptions(arguments_: readonly string[]): ParsedCliOptions {\n let profile: string | undefined;\n let explicitProfile = false;\n let allowOwnerProfile = false;\n let help = false;\n let version = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === \"--help\" || argument === \"-h\") {\n help = true;\n continue;\n }\n if (argument === \"--version\" || argument === \"-v\") {\n version = true;\n continue;\n }\n if (argument === \"--allow-owner-profile\") {\n allowOwnerProfile = true;\n continue;\n }\n if (argument === \"--profile\") {\n const value = arguments_[index + 1];\n if (value === undefined || value.startsWith(\"-\") || value.trim().length === 0) {\n throw new Error(\"--profile requires a non-empty profile name.\");\n }\n profile = value;\n explicitProfile = true;\n index += 1;\n continue;\n }\n if (argument?.startsWith(\"--profile=\")) {\n const value = argument.slice(\"--profile=\".length);\n if (value.trim().length === 0) throw new Error(\"--profile requires a non-empty profile name.\");\n profile = value;\n explicitProfile = true;\n continue;\n }\n throw new Error(`Unknown option: ${argument}`);\n }\n\n return { profile, explicitProfile, allowOwnerProfile, help, version };\n}\n\nexport async function main(arguments_: readonly string[] = process.argv.slice(2)): Promise<number> {\n let options: ParsedCliOptions;\n try {\n options = parseCliOptions(arguments_);\n } catch (error) {\n process.stderr.write(\"[tinycloud-mcp] Invalid command line.\\n\");\n return 2;\n }\n\n if (options.help) {\n process.stdout.write(HELP);\n return 0;\n }\n if (options.version) {\n process.stdout.write(`${MCP_VERSION}\\n`);\n return 0;\n }\n\n let profile: string;\n try {\n profile = await resolveInvocationProfileName(options.profile);\n } catch {\n process.stderr.write(\"[tinycloud-mcp] Could not select a profile.\\n\");\n return 2;\n }\n\n // The selected profile is now a value captured by the server closure. Every\n // operation receives it explicitly and cannot re-read TC_PROFILE/config.\n serveTinyCloudMcp({\n profile,\n explicitProfile: options.explicitProfile,\n allowOwnerProfile: options.allowOwnerProfile,\n });\n return 0;\n}\n\nfunction isDirectInvocation(): boolean {\n const argv = process.argv[1];\n if (argv === undefined) return false;\n return basename(argv) === \"cli.js\" || basename(argv) === \"cli.cjs\" || basename(argv) === \"tinycloud-mcp\";\n}\n\nif (isDirectInvocation()) {\n void main().then((code) => {\n if (code !== 0) process.exitCode = code;\n }).catch(() => {\n process.stderr.write(\"[tinycloud-mcp] Startup failed.\\n\");\n process.exitCode = 1;\n });\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { serveStdio, type StdioServerHandle } from \"@modelcontextprotocol/server/stdio\";\n\nimport { createJsonSchemaValidator, registerTinyCloudTools, type McpStartupSelection } from \"./tools.js\";\nimport { MCP_VERSION } from \"./version.js\";\n\nexport const MCP_SERVER_NAME = \"tinycloud-mcp\";\nexport { MCP_VERSION } from \"./version.js\";\nexport function createTinyCloudMcpServer(selection: McpStartupSelection): McpServer {\n const validator = createJsonSchemaValidator();\n const server = new McpServer(\n { name: MCP_SERVER_NAME, version: MCP_VERSION },\n { jsonSchemaValidator: validator },\n );\n registerTinyCloudTools(server, selection, validator);\n return server;\n}\n\n/** Start the only supported MCP transport: local stdio. */\nexport function serveTinyCloudMcp(selection: McpStartupSelection): StdioServerHandle {\n return serveStdio(\n () => createTinyCloudMcpServer(selection),\n { onerror: () => writeBoundedDiagnostic(\"MCP transport error\") },\n );\n}\n\nfunction writeBoundedDiagnostic(message: string): void {\n process.stderr.write(`[tinycloud-mcp] ${message}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { fromJsonSchema, type McpServer, type ToolAnnotations } from \"@modelcontextprotocol/server\";\nimport { addFormats, Ajv, AjvJsonSchemaValidator } from \"@modelcontextprotocol/server/validators/ajv\";\nimport { invokeOperation } from \"@tinycloud/operations\";\n\nimport { toMcpToolResult, type McpToolResult } from \"./results.js\";\n\nexport const TOOL_NAMES = [\n \"tinycloud_status\",\n \"tinycloud_auth_status\",\n \"tinycloud_auth_capabilities\",\n \"tinycloud_auth_request\",\n \"tinycloud_auth_import\",\n \"tinycloud_account_spaces_list\",\n \"tinycloud_account_applications_list\",\n \"tinycloud_kv_list\",\n \"tinycloud_kv_get\",\n \"tinycloud_secrets_get\",\n] as const;\n\nexport type ToolName = (typeof TOOL_NAMES)[number];\n\nexport interface McpStartupSelection {\n readonly profile: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n}\n\nexport interface McpInvocationTarget {\n readonly profile: string;\n readonly allowOwnerProfile?: true;\n}\n\n/** Project one startup selection into the only owner-sensitive target shape. */\nexport function invocationTargetForMcp(\n selection: McpStartupSelection,\n): McpInvocationTarget {\n return {\n profile: selection.profile,\n ...(selection.explicitProfile && selection.allowOwnerProfile\n ? { allowOwnerProfile: true }\n : {}),\n };\n}\n\ninterface CatalogOperation {\n readonly id: string;\n readonly version: number;\n readonly title: string;\n readonly description: string;\n readonly input: Record<string, unknown>;\n readonly result: Record<string, unknown>;\n}\n\ninterface OperationsCatalog {\n readonly operations: readonly CatalogOperation[];\n}\n\n// The require anchor is this module, never the consumer entrypoint. In ESM\n// tsup preserves import.meta.url; in CJS it rewrites the same module-relative\n// anchor to the generated __filename, so both formats stay in MCP's package\n// dependency boundary.\nconst packageRequire = createRequire(\n typeof __dirname === \"string\" ? join(__dirname, \"tools.cjs\") : import.meta.url,\n);\nconst generatedCatalog = packageRequire(\n \"@tinycloud/operations/operations.json\",\n) as OperationsCatalog;\n\ninterface ToolBinding {\n readonly name: ToolName;\n readonly operationId: string;\n readonly operationVersion: number;\n readonly readOnlyHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n}\n\nconst TOOL_BINDINGS: readonly ToolBinding[] = [\n {\n name: \"tinycloud_status\",\n operationId: \"tinycloud.status.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_status\",\n operationId: \"tinycloud.auth.status\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_capabilities\",\n operationId: \"tinycloud.auth.capabilities\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_request\",\n operationId: \"tinycloud.auth.request\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_import\",\n operationId: \"tinycloud.auth.import\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_account_spaces_list\",\n operationId: \"tinycloud.account.spaces.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_account_applications_list\",\n operationId: \"tinycloud.account.applications.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_list\",\n operationId: \"tinycloud.kv.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_get\",\n operationId: \"tinycloud.kv.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_secrets_get\",\n operationId: \"tinycloud.secrets.get\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: true,\n },\n] as const;\n\nexport function createJsonSchemaValidator(): AjvJsonSchemaValidator {\n const ajv = new Ajv({ strict: false });\n addFormats(ajv);\n return new AjvJsonSchemaValidator(ajv);\n}\n\nexport function registerTinyCloudTools(\n server: McpServer,\n selection: McpStartupSelection,\n validator: AjvJsonSchemaValidator,\n): void {\n const definitions = new Map(\n generatedCatalog.operations.map((operation) => [\n `${operation.id}@${operation.version}`,\n operation,\n ]),\n );\n\n for (const binding of TOOL_BINDINGS) {\n const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);\n if (operation === undefined) {\n throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);\n }\n\n const inputSchema = fromJsonSchema(\n operation.input as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const outputSchema = fromJsonSchema(\n operation.result as unknown as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const annotations: ToolAnnotations = {\n readOnlyHint: binding.readOnlyHint,\n idempotentHint: binding.idempotentHint,\n destructiveHint: false,\n openWorldHint: binding.openWorldHint,\n };\n\n server.registerTool(\n binding.name,\n {\n title: operation.title,\n description: operation.description,\n inputSchema,\n outputSchema,\n annotations,\n },\n async (input: unknown): Promise<McpToolResult> => {\n const result = await invokeOperation(\n binding.operationId,\n binding.operationVersion,\n invocationTargetForMcp(selection),\n input,\n );\n return toMcpToolResult(result);\n },\n );\n }\n}\n\nexport function toolBindingsForTest(): readonly ToolBinding[] {\n return TOOL_BINDINGS;\n}\n","/**\n * MCP has one structured result channel for a TinyCloud operation. Text is a\n * fixed, non-sensitive status line; it never serializes the operation result.\n */\nexport interface CanonicalOperationResult {\n readonly status: \"ok\" | \"authority_required\" | \"setup_required\" | \"error\";\n readonly [key: string]: unknown;\n}\n\nexport interface McpToolResult extends CallToolResult {\n readonly content: [{ readonly type: \"text\"; readonly text: string }];\n readonly structuredContent: CanonicalOperationResult;\n}\n\nexport function toMcpToolResult(result: unknown): McpToolResult {\n const canonical: CanonicalOperationResult = isCanonicalOperationResult(result)\n ? result\n : {\n status: \"error\",\n operation: {},\n context: {},\n error: { code: \"INTERNAL_ERROR\" },\n };\n\n return {\n content: [{ type: \"text\", text: resultSummary(canonical.status) }],\n structuredContent: canonical,\n };\n}\n\n/** The canonical envelope immediately before MCP protocol serialization. */\nexport function canonicalMcpAdapterResult(result: unknown): CanonicalOperationResult {\n return toMcpToolResult(result).structuredContent;\n}\n\nfunction isCanonicalOperationResult(value: unknown): value is CanonicalOperationResult {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const status = (value as { status?: unknown }).status;\n return status === \"ok\" ||\n status === \"authority_required\" ||\n status === \"setup_required\" ||\n status === \"error\";\n}\n\nfunction resultSummary(status: CanonicalOperationResult[\"status\"]): string {\n switch (status) {\n case \"ok\":\n return \"TinyCloud operation completed; use the structured result.\";\n case \"authority_required\":\n return \"TinyCloud authority is required; use the structured request and approval action.\";\n case \"setup_required\":\n return \"TinyCloud setup is required; use the structured setup action.\";\n case \"error\":\n return \"TinyCloud operation failed; use the structured error.\";\n }\n}\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n","{\n \"name\": \"@tinycloud/mcp\",\n \"version\": \"0.1.0-beta.2\",\n \"description\": \"TinyCloud delegated operations MCP server\",\n \"author\": \"TinyCloud, Inc.\",\n \"license\": \"EGPL\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"tinycloud-mcp\": \"./bin/tinycloud-mcp\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"types\": \"./dist/server.d.ts\",\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./tools\": {\n \"types\": \"./dist/tools.d.ts\",\n \"import\": \"./dist/tools.js\",\n \"require\": \"./dist/tools.cjs\"\n },\n \"./results\": {\n \"types\": \"./dist/results.d.ts\",\n \"import\": \"./dist/results.js\",\n \"require\": \"./dist/results.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"generated\",\n \"skills\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"bun run build && bun scripts/test.ts && bun run check:generated\",\n \"test:stdio\": \"bun run build && bun test src/stdio.test.ts\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"generate\": \"bun scripts/generate.ts\",\n \"check:generated\": \"bun scripts/generate.ts --check\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/server\": \"2.0.0-beta.4\",\n \"@tinycloud/operations\": \"0.1.0-beta.2\"\n },\n \"devDependencies\": {\n \"@modelcontextprotocol/client\": \"2.0.0-beta.4\",\n \"@types/node\": \"^20\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/tinycloudlabs/web-sdk\"\n }\n}\n","import packageMetadata from \"../package.json\";\n\nexport const MCP_VERSION = packageMetadata.version;\n"],"mappings":";AAAA,SAAS,gBAAgB;AAEzB,SAAS,oCAAoC;;;ACF7C,SAAS,iBAAiB;AAC1B,SAAS,kBAA0C;;;ACDnD,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AAErB,SAAS,sBAA4D;AACrE,SAAS,YAAY,KAAK,8BAA8B;AACxD,SAAS,uBAAuB;;;ACSzB,SAAS,gBAAgB,QAAgC;AAC9D,QAAM,YAAsC,2BAA2B,MAAM,IACzE,SACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW,CAAC;AAAA,IACZ,SAAS,CAAC;AAAA,IACV,OAAO,EAAE,MAAM,iBAAiB;AAAA,EAClC;AAEF,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,cAAc,UAAU,MAAM,EAAE,CAAC;AAAA,IACjE,mBAAmB;AAAA,EACrB;AACF;AAGO,SAAS,0BAA0B,QAA2C;AACnF,SAAO,gBAAgB,MAAM,EAAE;AAC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AA,EACT;AAEA,MAAI;AACJ,MAAI;AACF,cAAU,MAAM,6BAA6B,QAAQ,OAAO;AAAA,EAC9D,QAAQ;AACN,YAAQ,OAAO,MAAM,+CAA+C;AACpE,WAAO;AAAA,EACT;AAIA,oBAAkB;AAAA,IAChB;AAAA,IACA,iBAAiB,QAAQ;AAAA,IACzB,mBAAmB,QAAQ;AAAA,EAC7B,CAAC;AACD,SAAO;AACT;AAEA,SAAS,qBAA8B;AACrC,QAAM,OAAO,QAAQ,KAAK,CAAC;AAC3B,MAAI,SAAS,OAAW,QAAO;AAC/B,SAAO,SAAS,IAAI,MAAM,YAAY,SAAS,IAAI,MAAM,aAAa,SAAS,IAAI,MAAM;AAC3F;AAEA,IAAI,mBAAmB,GAAG;AACxB,OAAK,KAAK,EAAE,KAAK,CAAC,SAAS;AACzB,QAAI,SAAS,EAAG,SAAQ,WAAW;AAAA,EACrC,CAAC,EAAE,MAAM,MAAM;AACb,YAAQ,OAAO,MAAM,mCAAmC;AACxD,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/server.ts","../src/tools.ts","../src/results.ts","../package.json","../src/version.ts"],"sourcesContent":["import { basename } from \"node:path\";\n\nimport { resolveInvocationProfileName } from \"@tinycloud/operations/profile\";\n\nimport { serveTinyCloudMcp, MCP_VERSION } from \"./server.js\";\n\nexport interface ParsedCliOptions {\n readonly profile?: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n readonly help: boolean;\n readonly version: boolean;\n}\n\nconst HELP = `TinyCloud delegated operations MCP server\n\nUsage: tinycloud-mcp [options]\n\nOptions:\n --profile <name> Pin the TinyCloud profile for this process\n --allow-owner-profile Allow data execution for an explicitly selected owner profile\n --help Show this help\n --version Show the package version\n`;\n\nexport function parseCliOptions(arguments_: readonly string[]): ParsedCliOptions {\n let profile: string | undefined;\n let explicitProfile = false;\n let allowOwnerProfile = false;\n let help = false;\n let version = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === \"--help\" || argument === \"-h\") {\n help = true;\n continue;\n }\n if (argument === \"--version\" || argument === \"-v\") {\n version = true;\n continue;\n }\n if (argument === \"--allow-owner-profile\") {\n allowOwnerProfile = true;\n continue;\n }\n if (argument === \"--profile\") {\n const value = arguments_[index + 1];\n if (value === undefined || value.startsWith(\"-\") || value.trim().length === 0) {\n throw new Error(\"--profile requires a non-empty profile name.\");\n }\n profile = value;\n explicitProfile = true;\n index += 1;\n continue;\n }\n if (argument?.startsWith(\"--profile=\")) {\n const value = argument.slice(\"--profile=\".length);\n if (value.trim().length === 0) throw new Error(\"--profile requires a non-empty profile name.\");\n profile = value;\n explicitProfile = true;\n continue;\n }\n throw new Error(`Unknown option: ${argument}`);\n }\n\n return { profile, explicitProfile, allowOwnerProfile, help, version };\n}\n\nexport async function main(arguments_: readonly string[] = process.argv.slice(2)): Promise<number> {\n let options: ParsedCliOptions;\n try {\n options = parseCliOptions(arguments_);\n } catch (error) {\n process.stderr.write(\"[tinycloud-mcp] Invalid command line.\\n\");\n return 2;\n }\n\n if (options.help) {\n process.stdout.write(HELP);\n return 0;\n }\n if (options.version) {\n process.stdout.write(`${MCP_VERSION}\\n`);\n return 0;\n }\n\n let profile: string;\n try {\n profile = await resolveInvocationProfileName(options.profile);\n } catch {\n process.stderr.write(\"[tinycloud-mcp] Could not select a profile.\\n\");\n return 2;\n }\n\n // The selected profile is now a value captured by the server closure. Every\n // operation receives it explicitly and cannot re-read TC_PROFILE/config.\n serveTinyCloudMcp({\n profile,\n explicitProfile: options.explicitProfile,\n allowOwnerProfile: options.allowOwnerProfile,\n });\n return 0;\n}\n\nfunction isDirectInvocation(): boolean {\n const argv = process.argv[1];\n if (argv === undefined) return false;\n return basename(argv) === \"cli.js\" || basename(argv) === \"cli.cjs\" || basename(argv) === \"tinycloud-mcp\";\n}\n\nif (isDirectInvocation()) {\n void main().then((code) => {\n if (code !== 0) process.exitCode = code;\n }).catch(() => {\n process.stderr.write(\"[tinycloud-mcp] Startup failed.\\n\");\n process.exitCode = 1;\n });\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { serveStdio, type StdioServerHandle } from \"@modelcontextprotocol/server/stdio\";\n\nimport { createJsonSchemaValidator, registerTinyCloudTools, type McpStartupSelection } from \"./tools.js\";\nimport { MCP_VERSION } from \"./version.js\";\n\nexport const MCP_SERVER_NAME = \"tinycloud-mcp\";\nexport { MCP_VERSION } from \"./version.js\";\nexport function createTinyCloudMcpServer(selection: McpStartupSelection): McpServer {\n const validator = createJsonSchemaValidator();\n const server = new McpServer(\n { name: MCP_SERVER_NAME, version: MCP_VERSION },\n { jsonSchemaValidator: validator },\n );\n registerTinyCloudTools(server, selection, validator);\n return server;\n}\n\n/** Start the only supported MCP transport: local stdio. */\nexport function serveTinyCloudMcp(selection: McpStartupSelection): StdioServerHandle {\n return serveStdio(\n () => createTinyCloudMcpServer(selection),\n { onerror: () => writeBoundedDiagnostic(\"MCP transport error\") },\n );\n}\n\nfunction writeBoundedDiagnostic(message: string): void {\n process.stderr.write(`[tinycloud-mcp] ${message}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { fromJsonSchema, type McpServer, type ToolAnnotations } from \"@modelcontextprotocol/server\";\nimport { addFormats, Ajv, AjvJsonSchemaValidator } from \"@modelcontextprotocol/server/validators/ajv\";\nimport { invokeOperation } from \"@tinycloud/operations\";\n\nimport { toMcpToolResult, type McpToolResult } from \"./results.js\";\n\nexport const TOOL_NAMES = [\n \"tinycloud_status\",\n \"tinycloud_auth_status\",\n \"tinycloud_auth_capabilities\",\n \"tinycloud_auth_request\",\n \"tinycloud_auth_import\",\n \"tinycloud_account_spaces_list\",\n \"tinycloud_account_applications_list\",\n \"tinycloud_kv_list\",\n \"tinycloud_kv_get\",\n \"tinycloud_secrets_get\",\n] as const;\n\nexport type ToolName = (typeof TOOL_NAMES)[number];\n\nexport interface McpStartupSelection {\n readonly profile: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n}\n\nexport interface McpInvocationTarget {\n readonly profile: string;\n readonly allowOwnerProfile?: true;\n}\n\n/** Project one startup selection into the only owner-sensitive target shape. */\nexport function invocationTargetForMcp(\n selection: McpStartupSelection,\n): McpInvocationTarget {\n return {\n profile: selection.profile,\n ...(selection.explicitProfile && selection.allowOwnerProfile\n ? { allowOwnerProfile: true }\n : {}),\n };\n}\n\ninterface CatalogOperation {\n readonly id: string;\n readonly version: number;\n readonly title: string;\n readonly description: string;\n readonly input: Record<string, unknown>;\n readonly result: Record<string, unknown>;\n}\n\ninterface OperationsCatalog {\n readonly operations: readonly CatalogOperation[];\n}\n\n// The require anchor is this module, never the consumer entrypoint. In ESM\n// tsup preserves import.meta.url; in CJS it rewrites the same module-relative\n// anchor to the generated __filename, so both formats stay in MCP's package\n// dependency boundary.\nconst packageRequire = createRequire(\n typeof __dirname === \"string\" ? join(__dirname, \"tools.cjs\") : import.meta.url,\n);\nconst generatedCatalog = packageRequire(\n \"@tinycloud/operations/operations.json\",\n) as OperationsCatalog;\n\ninterface ToolBinding {\n readonly name: ToolName;\n readonly operationId: string;\n readonly operationVersion: number;\n readonly readOnlyHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n}\n\nconst TOOL_BINDINGS: readonly ToolBinding[] = [\n {\n name: \"tinycloud_status\",\n operationId: \"tinycloud.status.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_status\",\n operationId: \"tinycloud.auth.status\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_capabilities\",\n operationId: \"tinycloud.auth.capabilities\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_request\",\n operationId: \"tinycloud.auth.request\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_import\",\n operationId: \"tinycloud.auth.import\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_account_spaces_list\",\n operationId: \"tinycloud.account.spaces.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_account_applications_list\",\n operationId: \"tinycloud.account.applications.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_list\",\n operationId: \"tinycloud.kv.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_get\",\n operationId: \"tinycloud.kv.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_secrets_get\",\n operationId: \"tinycloud.secrets.get\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: true,\n },\n] as const;\n\nexport function createJsonSchemaValidator(): AjvJsonSchemaValidator {\n const ajv = new Ajv({ strict: false });\n addFormats(ajv);\n return new AjvJsonSchemaValidator(ajv);\n}\n\nexport function registerTinyCloudTools(\n server: McpServer,\n selection: McpStartupSelection,\n validator: AjvJsonSchemaValidator,\n): void {\n const definitions = new Map(\n generatedCatalog.operations.map((operation) => [\n `${operation.id}@${operation.version}`,\n operation,\n ]),\n );\n\n for (const binding of TOOL_BINDINGS) {\n const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);\n if (operation === undefined) {\n throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);\n }\n\n const inputSchema = fromJsonSchema(\n operation.input as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const outputSchema = fromJsonSchema(\n operation.result as unknown as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const annotations: ToolAnnotations = {\n readOnlyHint: binding.readOnlyHint,\n idempotentHint: binding.idempotentHint,\n destructiveHint: false,\n openWorldHint: binding.openWorldHint,\n };\n\n server.registerTool(\n binding.name,\n {\n title: operation.title,\n description: operation.description,\n inputSchema,\n outputSchema,\n annotations,\n },\n async (input: unknown): Promise<McpToolResult> => {\n const result = await invokeOperation(\n binding.operationId,\n binding.operationVersion,\n invocationTargetForMcp(selection),\n input,\n );\n return toMcpToolResult(result);\n },\n );\n }\n}\n\nexport function toolBindingsForTest(): readonly ToolBinding[] {\n return TOOL_BINDINGS;\n}\n","/**\n * MCP has one structured result channel for a TinyCloud operation. Text is a\n * fixed, non-sensitive status line; it never serializes the operation result.\n */\nexport interface CanonicalOperationResult {\n readonly status: \"ok\" | \"authority_required\" | \"setup_required\" | \"error\";\n readonly [key: string]: unknown;\n}\n\nexport interface McpToolResult extends CallToolResult {\n readonly content: [{ readonly type: \"text\"; readonly text: string }];\n readonly structuredContent: CanonicalOperationResult;\n}\n\nexport function toMcpToolResult(result: unknown): McpToolResult {\n const canonical: CanonicalOperationResult = isCanonicalOperationResult(result)\n ? result\n : {\n status: \"error\",\n operation: {},\n context: {},\n error: { code: \"INTERNAL_ERROR\" },\n };\n\n return {\n content: [{ type: \"text\", text: resultSummary(canonical.status) }],\n structuredContent: canonical,\n };\n}\n\n/** The canonical envelope immediately before MCP protocol serialization. */\nexport function canonicalMcpAdapterResult(result: unknown): CanonicalOperationResult {\n return toMcpToolResult(result).structuredContent;\n}\n\nfunction isCanonicalOperationResult(value: unknown): value is CanonicalOperationResult {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const status = (value as { status?: unknown }).status;\n return status === \"ok\" ||\n status === \"authority_required\" ||\n status === \"setup_required\" ||\n status === \"error\";\n}\n\nfunction resultSummary(status: CanonicalOperationResult[\"status\"]): string {\n switch (status) {\n case \"ok\":\n return \"TinyCloud operation completed; use the structured result.\";\n case \"authority_required\":\n return \"TinyCloud authority is required; use the structured request and approval action.\";\n case \"setup_required\":\n return \"TinyCloud setup is required; use the structured setup action.\";\n case \"error\":\n return \"TinyCloud operation failed; use the structured error.\";\n }\n}\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n","{\n \"name\": \"@tinycloud/mcp\",\n \"version\": \"0.1.0\",\n \"description\": \"TinyCloud delegated operations MCP server\",\n \"author\": \"TinyCloud, Inc.\",\n \"license\": \"EGPL\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"tinycloud-mcp\": \"./bin/tinycloud-mcp\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"types\": \"./dist/server.d.ts\",\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./tools\": {\n \"types\": \"./dist/tools.d.ts\",\n \"import\": \"./dist/tools.js\",\n \"require\": \"./dist/tools.cjs\"\n },\n \"./results\": {\n \"types\": \"./dist/results.d.ts\",\n \"import\": \"./dist/results.js\",\n \"require\": \"./dist/results.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"generated\",\n \"skills\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"bun run build && bun scripts/test.ts && bun run check:generated\",\n \"test:stdio\": \"bun run build && bun test src/stdio.test.ts\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"generate\": \"bun scripts/generate.ts\",\n \"check:generated\": \"bun scripts/generate.ts --check\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/server\": \"2.0.0-beta.4\",\n \"@tinycloud/operations\": \"0.1.0\"\n },\n \"devDependencies\": {\n \"@modelcontextprotocol/client\": \"2.0.0-beta.4\",\n \"@types/node\": \"^20\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/tinycloudlabs/web-sdk\"\n }\n}\n","import packageMetadata from \"../package.json\";\n\nexport const MCP_VERSION = packageMetadata.version;\n"],"mappings":";AAAA,SAAS,gBAAgB;AAEzB,SAAS,oCAAoC;;;ACF7C,SAAS,iBAAiB;AAC1B,SAAS,kBAA0C;;;ACDnD,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AAErB,SAAS,sBAA4D;AACrE,SAAS,YAAY,KAAK,8BAA8B;AACxD,SAAS,uBAAuB;;;ACSzB,SAAS,gBAAgB,QAAgC;AAC9D,QAAM,YAAsC,2BAA2B,MAAM,IACzE,SACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW,CAAC;AAAA,IACZ,SAAS,CAAC;AAAA,IACV,OAAO,EAAE,MAAM,iBAAiB;AAAA,EAClC;AAEF,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,cAAc,UAAU,MAAM,EAAE,CAAC;AAAA,IACjE,mBAAmB;AAAA,EACrB;AACF;AAGO,SAAS,0BAA0B,QAA2C;AACnF,SAAO,gBAAgB,MAAM,EAAE;AACjC;AAEA,SAAS,2BAA2B,OAAmD;AACrF,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,SAAU,MAA+B;AAC/C,SAAO,WAAW,QAChB,WAAW,wBACX,WAAW,oBACX,WAAW;AACf;AAEA,SAAS,cAAc,QAAoD;AACzE,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AACF;;;AD9CO,IAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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,GAAG;AACxB,OAAK,KAAK,EAAE,KAAK,CAAC,SAAS;AACzB,QAAI,SAAS,EAAG,SAAQ,WAAW;AAAA,EACrC,CAAC,EAAE,MAAM,MAAM;AACb,YAAQ,OAAO,MAAM,mCAAmC;AACxD,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":[]}
|
package/dist/server.cjs
CHANGED
|
@@ -219,7 +219,7 @@ function registerTinyCloudTools(server, selection, validator) {
|
|
|
219
219
|
// package.json
|
|
220
220
|
var package_default = {
|
|
221
221
|
name: "@tinycloud/mcp",
|
|
222
|
-
version: "0.1.0
|
|
222
|
+
version: "0.1.0",
|
|
223
223
|
description: "TinyCloud delegated operations MCP server",
|
|
224
224
|
author: "TinyCloud, Inc.",
|
|
225
225
|
license: "EGPL",
|
|
@@ -272,7 +272,7 @@ var package_default = {
|
|
|
272
272
|
},
|
|
273
273
|
dependencies: {
|
|
274
274
|
"@modelcontextprotocol/server": "2.0.0-beta.4",
|
|
275
|
-
"@tinycloud/operations": "0.1.0
|
|
275
|
+
"@tinycloud/operations": "0.1.0"
|
|
276
276
|
},
|
|
277
277
|
devDependencies: {
|
|
278
278
|
"@modelcontextprotocol/client": "2.0.0-beta.4",
|
package/dist/server.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.ts","../src/tools.ts","../src/results.ts","../package.json","../src/version.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/server\";\nimport { serveStdio, type StdioServerHandle } from \"@modelcontextprotocol/server/stdio\";\n\nimport { createJsonSchemaValidator, registerTinyCloudTools, type McpStartupSelection } from \"./tools.js\";\nimport { MCP_VERSION } from \"./version.js\";\n\nexport const MCP_SERVER_NAME = \"tinycloud-mcp\";\nexport { MCP_VERSION } from \"./version.js\";\nexport function createTinyCloudMcpServer(selection: McpStartupSelection): McpServer {\n const validator = createJsonSchemaValidator();\n const server = new McpServer(\n { name: MCP_SERVER_NAME, version: MCP_VERSION },\n { jsonSchemaValidator: validator },\n );\n registerTinyCloudTools(server, selection, validator);\n return server;\n}\n\n/** Start the only supported MCP transport: local stdio. */\nexport function serveTinyCloudMcp(selection: McpStartupSelection): StdioServerHandle {\n return serveStdio(\n () => createTinyCloudMcpServer(selection),\n { onerror: () => writeBoundedDiagnostic(\"MCP transport error\") },\n );\n}\n\nfunction writeBoundedDiagnostic(message: string): void {\n process.stderr.write(`[tinycloud-mcp] ${message}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { fromJsonSchema, type McpServer, type ToolAnnotations } from \"@modelcontextprotocol/server\";\nimport { addFormats, Ajv, AjvJsonSchemaValidator } from \"@modelcontextprotocol/server/validators/ajv\";\nimport { invokeOperation } from \"@tinycloud/operations\";\n\nimport { toMcpToolResult, type McpToolResult } from \"./results.js\";\n\nexport const TOOL_NAMES = [\n \"tinycloud_status\",\n \"tinycloud_auth_status\",\n \"tinycloud_auth_capabilities\",\n \"tinycloud_auth_request\",\n \"tinycloud_auth_import\",\n \"tinycloud_account_spaces_list\",\n \"tinycloud_account_applications_list\",\n \"tinycloud_kv_list\",\n \"tinycloud_kv_get\",\n \"tinycloud_secrets_get\",\n] as const;\n\nexport type ToolName = (typeof TOOL_NAMES)[number];\n\nexport interface McpStartupSelection {\n readonly profile: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n}\n\nexport interface McpInvocationTarget {\n readonly profile: string;\n readonly allowOwnerProfile?: true;\n}\n\n/** Project one startup selection into the only owner-sensitive target shape. */\nexport function invocationTargetForMcp(\n selection: McpStartupSelection,\n): McpInvocationTarget {\n return {\n profile: selection.profile,\n ...(selection.explicitProfile && selection.allowOwnerProfile\n ? { allowOwnerProfile: true }\n : {}),\n };\n}\n\ninterface CatalogOperation {\n readonly id: string;\n readonly version: number;\n readonly title: string;\n readonly description: string;\n readonly input: Record<string, unknown>;\n readonly result: Record<string, unknown>;\n}\n\ninterface OperationsCatalog {\n readonly operations: readonly CatalogOperation[];\n}\n\n// The require anchor is this module, never the consumer entrypoint. In ESM\n// tsup preserves import.meta.url; in CJS it rewrites the same module-relative\n// anchor to the generated __filename, so both formats stay in MCP's package\n// dependency boundary.\nconst packageRequire = createRequire(\n typeof __dirname === \"string\" ? join(__dirname, \"tools.cjs\") : import.meta.url,\n);\nconst generatedCatalog = packageRequire(\n \"@tinycloud/operations/operations.json\",\n) as OperationsCatalog;\n\ninterface ToolBinding {\n readonly name: ToolName;\n readonly operationId: string;\n readonly operationVersion: number;\n readonly readOnlyHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n}\n\nconst TOOL_BINDINGS: readonly ToolBinding[] = [\n {\n name: \"tinycloud_status\",\n operationId: \"tinycloud.status.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_status\",\n operationId: \"tinycloud.auth.status\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_capabilities\",\n operationId: \"tinycloud.auth.capabilities\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_request\",\n operationId: \"tinycloud.auth.request\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_import\",\n operationId: \"tinycloud.auth.import\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_account_spaces_list\",\n operationId: \"tinycloud.account.spaces.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_account_applications_list\",\n operationId: \"tinycloud.account.applications.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_list\",\n operationId: \"tinycloud.kv.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_get\",\n operationId: \"tinycloud.kv.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_secrets_get\",\n operationId: \"tinycloud.secrets.get\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: true,\n },\n] as const;\n\nexport function createJsonSchemaValidator(): AjvJsonSchemaValidator {\n const ajv = new Ajv({ strict: false });\n addFormats(ajv);\n return new AjvJsonSchemaValidator(ajv);\n}\n\nexport function registerTinyCloudTools(\n server: McpServer,\n selection: McpStartupSelection,\n validator: AjvJsonSchemaValidator,\n): void {\n const definitions = new Map(\n generatedCatalog.operations.map((operation) => [\n `${operation.id}@${operation.version}`,\n operation,\n ]),\n );\n\n for (const binding of TOOL_BINDINGS) {\n const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);\n if (operation === undefined) {\n throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);\n }\n\n const inputSchema = fromJsonSchema(\n operation.input as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const outputSchema = fromJsonSchema(\n operation.result as unknown as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const annotations: ToolAnnotations = {\n readOnlyHint: binding.readOnlyHint,\n idempotentHint: binding.idempotentHint,\n destructiveHint: false,\n openWorldHint: binding.openWorldHint,\n };\n\n server.registerTool(\n binding.name,\n {\n title: operation.title,\n description: operation.description,\n inputSchema,\n outputSchema,\n annotations,\n },\n async (input: unknown): Promise<McpToolResult> => {\n const result = await invokeOperation(\n binding.operationId,\n binding.operationVersion,\n invocationTargetForMcp(selection),\n input,\n );\n return toMcpToolResult(result);\n },\n );\n }\n}\n\nexport function toolBindingsForTest(): readonly ToolBinding[] {\n return TOOL_BINDINGS;\n}\n","/**\n * MCP has one structured result channel for a TinyCloud operation. Text is a\n * fixed, non-sensitive status line; it never serializes the operation result.\n */\nexport interface CanonicalOperationResult {\n readonly status: \"ok\" | \"authority_required\" | \"setup_required\" | \"error\";\n readonly [key: string]: unknown;\n}\n\nexport interface McpToolResult extends CallToolResult {\n readonly content: [{ readonly type: \"text\"; readonly text: string }];\n readonly structuredContent: CanonicalOperationResult;\n}\n\nexport function toMcpToolResult(result: unknown): McpToolResult {\n const canonical: CanonicalOperationResult = isCanonicalOperationResult(result)\n ? result\n : {\n status: \"error\",\n operation: {},\n context: {},\n error: { code: \"INTERNAL_ERROR\" },\n };\n\n return {\n content: [{ type: \"text\", text: resultSummary(canonical.status) }],\n structuredContent: canonical,\n };\n}\n\n/** The canonical envelope immediately before MCP protocol serialization. */\nexport function canonicalMcpAdapterResult(result: unknown): CanonicalOperationResult {\n return toMcpToolResult(result).structuredContent;\n}\n\nfunction isCanonicalOperationResult(value: unknown): value is CanonicalOperationResult {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const status = (value as { status?: unknown }).status;\n return status === \"ok\" ||\n status === \"authority_required\" ||\n status === \"setup_required\" ||\n status === \"error\";\n}\n\nfunction resultSummary(status: CanonicalOperationResult[\"status\"]): string {\n switch (status) {\n case \"ok\":\n return \"TinyCloud operation completed; use the structured result.\";\n case \"authority_required\":\n return \"TinyCloud authority is required; use the structured request and approval action.\";\n case \"setup_required\":\n return \"TinyCloud setup is required; use the structured setup action.\";\n case \"error\":\n return \"TinyCloud operation failed; use the structured error.\";\n }\n}\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n","{\n \"name\": \"@tinycloud/mcp\",\n \"version\": \"0.1.0-beta.2\",\n \"description\": \"TinyCloud delegated operations MCP server\",\n \"author\": \"TinyCloud, Inc.\",\n \"license\": \"EGPL\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"tinycloud-mcp\": \"./bin/tinycloud-mcp\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"types\": \"./dist/server.d.ts\",\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./tools\": {\n \"types\": \"./dist/tools.d.ts\",\n \"import\": \"./dist/tools.js\",\n \"require\": \"./dist/tools.cjs\"\n },\n \"./results\": {\n \"types\": \"./dist/results.d.ts\",\n \"import\": \"./dist/results.js\",\n \"require\": \"./dist/results.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"generated\",\n \"skills\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"bun run build && bun scripts/test.ts && bun run check:generated\",\n \"test:stdio\": \"bun run build && bun test src/stdio.test.ts\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"generate\": \"bun scripts/generate.ts\",\n \"check:generated\": \"bun scripts/generate.ts --check\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/server\": \"2.0.0-beta.4\",\n \"@tinycloud/operations\": \"0.1.0-beta.2\"\n },\n \"devDependencies\": {\n \"@modelcontextprotocol/client\": \"2.0.0-beta.4\",\n \"@types/node\": \"^20\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/tinycloudlabs/web-sdk\"\n }\n}\n","import packageMetadata from \"../package.json\";\n\nexport const MCP_VERSION = packageMetadata.version;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,iBAA0B;AAC1B,mBAAmD;;;ACDnD,yBAA8B;AAC9B,uBAAqB;AAErB,oBAAqE;AACrE,iBAAwD;AACxD,wBAAgC;;;ACSzB,SAAS,gBAAgB,QAAgC;AAC9D,QAAM,YAAs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;AACrD;","names":["import_server"]}
|
|
1
|
+
{"version":3,"sources":["../src/server.ts","../src/tools.ts","../src/results.ts","../package.json","../src/version.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/server\";\nimport { serveStdio, type StdioServerHandle } from \"@modelcontextprotocol/server/stdio\";\n\nimport { createJsonSchemaValidator, registerTinyCloudTools, type McpStartupSelection } from \"./tools.js\";\nimport { MCP_VERSION } from \"./version.js\";\n\nexport const MCP_SERVER_NAME = \"tinycloud-mcp\";\nexport { MCP_VERSION } from \"./version.js\";\nexport function createTinyCloudMcpServer(selection: McpStartupSelection): McpServer {\n const validator = createJsonSchemaValidator();\n const server = new McpServer(\n { name: MCP_SERVER_NAME, version: MCP_VERSION },\n { jsonSchemaValidator: validator },\n );\n registerTinyCloudTools(server, selection, validator);\n return server;\n}\n\n/** Start the only supported MCP transport: local stdio. */\nexport function serveTinyCloudMcp(selection: McpStartupSelection): StdioServerHandle {\n return serveStdio(\n () => createTinyCloudMcpServer(selection),\n { onerror: () => writeBoundedDiagnostic(\"MCP transport error\") },\n );\n}\n\nfunction writeBoundedDiagnostic(message: string): void {\n process.stderr.write(`[tinycloud-mcp] ${message}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { fromJsonSchema, type McpServer, type ToolAnnotations } from \"@modelcontextprotocol/server\";\nimport { addFormats, Ajv, AjvJsonSchemaValidator } from \"@modelcontextprotocol/server/validators/ajv\";\nimport { invokeOperation } from \"@tinycloud/operations\";\n\nimport { toMcpToolResult, type McpToolResult } from \"./results.js\";\n\nexport const TOOL_NAMES = [\n \"tinycloud_status\",\n \"tinycloud_auth_status\",\n \"tinycloud_auth_capabilities\",\n \"tinycloud_auth_request\",\n \"tinycloud_auth_import\",\n \"tinycloud_account_spaces_list\",\n \"tinycloud_account_applications_list\",\n \"tinycloud_kv_list\",\n \"tinycloud_kv_get\",\n \"tinycloud_secrets_get\",\n] as const;\n\nexport type ToolName = (typeof TOOL_NAMES)[number];\n\nexport interface McpStartupSelection {\n readonly profile: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n}\n\nexport interface McpInvocationTarget {\n readonly profile: string;\n readonly allowOwnerProfile?: true;\n}\n\n/** Project one startup selection into the only owner-sensitive target shape. */\nexport function invocationTargetForMcp(\n selection: McpStartupSelection,\n): McpInvocationTarget {\n return {\n profile: selection.profile,\n ...(selection.explicitProfile && selection.allowOwnerProfile\n ? { allowOwnerProfile: true }\n : {}),\n };\n}\n\ninterface CatalogOperation {\n readonly id: string;\n readonly version: number;\n readonly title: string;\n readonly description: string;\n readonly input: Record<string, unknown>;\n readonly result: Record<string, unknown>;\n}\n\ninterface OperationsCatalog {\n readonly operations: readonly CatalogOperation[];\n}\n\n// The require anchor is this module, never the consumer entrypoint. In ESM\n// tsup preserves import.meta.url; in CJS it rewrites the same module-relative\n// anchor to the generated __filename, so both formats stay in MCP's package\n// dependency boundary.\nconst packageRequire = createRequire(\n typeof __dirname === \"string\" ? join(__dirname, \"tools.cjs\") : import.meta.url,\n);\nconst generatedCatalog = packageRequire(\n \"@tinycloud/operations/operations.json\",\n) as OperationsCatalog;\n\ninterface ToolBinding {\n readonly name: ToolName;\n readonly operationId: string;\n readonly operationVersion: number;\n readonly readOnlyHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n}\n\nconst TOOL_BINDINGS: readonly ToolBinding[] = [\n {\n name: \"tinycloud_status\",\n operationId: \"tinycloud.status.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_status\",\n operationId: \"tinycloud.auth.status\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_capabilities\",\n operationId: \"tinycloud.auth.capabilities\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_request\",\n operationId: \"tinycloud.auth.request\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_import\",\n operationId: \"tinycloud.auth.import\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_account_spaces_list\",\n operationId: \"tinycloud.account.spaces.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_account_applications_list\",\n operationId: \"tinycloud.account.applications.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_list\",\n operationId: \"tinycloud.kv.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_get\",\n operationId: \"tinycloud.kv.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_secrets_get\",\n operationId: \"tinycloud.secrets.get\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: true,\n },\n] as const;\n\nexport function createJsonSchemaValidator(): AjvJsonSchemaValidator {\n const ajv = new Ajv({ strict: false });\n addFormats(ajv);\n return new AjvJsonSchemaValidator(ajv);\n}\n\nexport function registerTinyCloudTools(\n server: McpServer,\n selection: McpStartupSelection,\n validator: AjvJsonSchemaValidator,\n): void {\n const definitions = new Map(\n generatedCatalog.operations.map((operation) => [\n `${operation.id}@${operation.version}`,\n operation,\n ]),\n );\n\n for (const binding of TOOL_BINDINGS) {\n const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);\n if (operation === undefined) {\n throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);\n }\n\n const inputSchema = fromJsonSchema(\n operation.input as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const outputSchema = fromJsonSchema(\n operation.result as unknown as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const annotations: ToolAnnotations = {\n readOnlyHint: binding.readOnlyHint,\n idempotentHint: binding.idempotentHint,\n destructiveHint: false,\n openWorldHint: binding.openWorldHint,\n };\n\n server.registerTool(\n binding.name,\n {\n title: operation.title,\n description: operation.description,\n inputSchema,\n outputSchema,\n annotations,\n },\n async (input: unknown): Promise<McpToolResult> => {\n const result = await invokeOperation(\n binding.operationId,\n binding.operationVersion,\n invocationTargetForMcp(selection),\n input,\n );\n return toMcpToolResult(result);\n },\n );\n }\n}\n\nexport function toolBindingsForTest(): readonly ToolBinding[] {\n return TOOL_BINDINGS;\n}\n","/**\n * MCP has one structured result channel for a TinyCloud operation. Text is a\n * fixed, non-sensitive status line; it never serializes the operation result.\n */\nexport interface CanonicalOperationResult {\n readonly status: \"ok\" | \"authority_required\" | \"setup_required\" | \"error\";\n readonly [key: string]: unknown;\n}\n\nexport interface McpToolResult extends CallToolResult {\n readonly content: [{ readonly type: \"text\"; readonly text: string }];\n readonly structuredContent: CanonicalOperationResult;\n}\n\nexport function toMcpToolResult(result: unknown): McpToolResult {\n const canonical: CanonicalOperationResult = isCanonicalOperationResult(result)\n ? result\n : {\n status: \"error\",\n operation: {},\n context: {},\n error: { code: \"INTERNAL_ERROR\" },\n };\n\n return {\n content: [{ type: \"text\", text: resultSummary(canonical.status) }],\n structuredContent: canonical,\n };\n}\n\n/** The canonical envelope immediately before MCP protocol serialization. */\nexport function canonicalMcpAdapterResult(result: unknown): CanonicalOperationResult {\n return toMcpToolResult(result).structuredContent;\n}\n\nfunction isCanonicalOperationResult(value: unknown): value is CanonicalOperationResult {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const status = (value as { status?: unknown }).status;\n return status === \"ok\" ||\n status === \"authority_required\" ||\n status === \"setup_required\" ||\n status === \"error\";\n}\n\nfunction resultSummary(status: CanonicalOperationResult[\"status\"]): string {\n switch (status) {\n case \"ok\":\n return \"TinyCloud operation completed; use the structured result.\";\n case \"authority_required\":\n return \"TinyCloud authority is required; use the structured request and approval action.\";\n case \"setup_required\":\n return \"TinyCloud setup is required; use the structured setup action.\";\n case \"error\":\n return \"TinyCloud operation failed; use the structured error.\";\n }\n}\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n","{\n \"name\": \"@tinycloud/mcp\",\n \"version\": \"0.1.0\",\n \"description\": \"TinyCloud delegated operations MCP server\",\n \"author\": \"TinyCloud, Inc.\",\n \"license\": \"EGPL\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"tinycloud-mcp\": \"./bin/tinycloud-mcp\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"types\": \"./dist/server.d.ts\",\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./tools\": {\n \"types\": \"./dist/tools.d.ts\",\n \"import\": \"./dist/tools.js\",\n \"require\": \"./dist/tools.cjs\"\n },\n \"./results\": {\n \"types\": \"./dist/results.d.ts\",\n \"import\": \"./dist/results.js\",\n \"require\": \"./dist/results.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"generated\",\n \"skills\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"bun run build && bun scripts/test.ts && bun run check:generated\",\n \"test:stdio\": \"bun run build && bun test src/stdio.test.ts\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"generate\": \"bun scripts/generate.ts\",\n \"check:generated\": \"bun scripts/generate.ts --check\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/server\": \"2.0.0-beta.4\",\n \"@tinycloud/operations\": \"0.1.0\"\n },\n \"devDependencies\": {\n \"@modelcontextprotocol/client\": \"2.0.0-beta.4\",\n \"@types/node\": \"^20\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/tinycloudlabs/web-sdk\"\n }\n}\n","import packageMetadata from \"../package.json\";\n\nexport const MCP_VERSION = packageMetadata.version;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,iBAA0B;AAC1B,mBAAmD;;;ACDnD,yBAA8B;AAC9B,uBAAqB;AAErB,oBAAqE;AACrE,iBAAwD;AACxD,wBAAgC;;;ACSzB,SAAS,gBAAgB,QAAgC;AAC9D,QAAM,YAAsC,2BAA2B,MAAM,IACzE,SACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW,CAAC;AAAA,IACZ,SAAS,CAAC;AAAA,IACV,OAAO,EAAE,MAAM,iBAAiB;AAAA,EAClC;AAEF,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,cAAc,UAAU,MAAM,EAAE,CAAC;AAAA,IACjE,mBAAmB;AAAA,EACrB;AACF;AAOA,SAAS,2BAA2B,OAAmD;AACrF,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,SAAU,MAA+B;AAC/C,SAAO,WAAW,QAChB,WAAW,wBACX,WAAW,oBACX,WAAW;AACf;AAEA,SAAS,cAAc,QAAoD;AACzE,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AACF;;;ADvDA;AAoCO,SAAS,uBACd,WACqB;AACrB,SAAO;AAAA,IACL,SAAS,UAAU;AAAA,IACnB,GAAI,UAAU,mBAAmB,UAAU,oBACvC,EAAE,mBAAmB,KAAK,IAC1B,CAAC;AAAA,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,kBAAkB;AAExB,SAAS,yBAAyB,WAA2C;AAClF,QAAM,YAAY,0BAA0B;AAC5C,QAAM,SAAS,IAAI;AAAA,IACjB,EAAE,MAAM,iBAAiB,SAAS,YAAY;AAAA,IAC9C,EAAE,qBAAqB,UAAU;AAAA,EACnC;AACA,yBAAuB,QAAQ,WAAW,SAAS;AACnD,SAAO;AACT;AAGO,SAAS,kBAAkB,WAAmD;AACnF,aAAO;AAAA,IACL,MAAM,yBAAyB,SAAS;AAAA,IACxC,EAAE,SAAS,MAAM,uBAAuB,qBAAqB,EAAE;AAAA,EACjE;AACF;AAEA,SAAS,uBAAuB,SAAuB;AACrD,UAAQ,OAAO,MAAM,mBAAmB,OAAO;AAAA,CAAI;AACrD;","names":["import_server"]}
|
package/dist/server.js
CHANGED
|
@@ -191,7 +191,7 @@ function registerTinyCloudTools(server, selection, validator) {
|
|
|
191
191
|
// package.json
|
|
192
192
|
var package_default = {
|
|
193
193
|
name: "@tinycloud/mcp",
|
|
194
|
-
version: "0.1.0
|
|
194
|
+
version: "0.1.0",
|
|
195
195
|
description: "TinyCloud delegated operations MCP server",
|
|
196
196
|
author: "TinyCloud, Inc.",
|
|
197
197
|
license: "EGPL",
|
|
@@ -244,7 +244,7 @@ var package_default = {
|
|
|
244
244
|
},
|
|
245
245
|
dependencies: {
|
|
246
246
|
"@modelcontextprotocol/server": "2.0.0-beta.4",
|
|
247
|
-
"@tinycloud/operations": "0.1.0
|
|
247
|
+
"@tinycloud/operations": "0.1.0"
|
|
248
248
|
},
|
|
249
249
|
devDependencies: {
|
|
250
250
|
"@modelcontextprotocol/client": "2.0.0-beta.4",
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.ts","../src/tools.ts","../src/results.ts","../package.json","../src/version.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/server\";\nimport { serveStdio, type StdioServerHandle } from \"@modelcontextprotocol/server/stdio\";\n\nimport { createJsonSchemaValidator, registerTinyCloudTools, type McpStartupSelection } from \"./tools.js\";\nimport { MCP_VERSION } from \"./version.js\";\n\nexport const MCP_SERVER_NAME = \"tinycloud-mcp\";\nexport { MCP_VERSION } from \"./version.js\";\nexport function createTinyCloudMcpServer(selection: McpStartupSelection): McpServer {\n const validator = createJsonSchemaValidator();\n const server = new McpServer(\n { name: MCP_SERVER_NAME, version: MCP_VERSION },\n { jsonSchemaValidator: validator },\n );\n registerTinyCloudTools(server, selection, validator);\n return server;\n}\n\n/** Start the only supported MCP transport: local stdio. */\nexport function serveTinyCloudMcp(selection: McpStartupSelection): StdioServerHandle {\n return serveStdio(\n () => createTinyCloudMcpServer(selection),\n { onerror: () => writeBoundedDiagnostic(\"MCP transport error\") },\n );\n}\n\nfunction writeBoundedDiagnostic(message: string): void {\n process.stderr.write(`[tinycloud-mcp] ${message}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { fromJsonSchema, type McpServer, type ToolAnnotations } from \"@modelcontextprotocol/server\";\nimport { addFormats, Ajv, AjvJsonSchemaValidator } from \"@modelcontextprotocol/server/validators/ajv\";\nimport { invokeOperation } from \"@tinycloud/operations\";\n\nimport { toMcpToolResult, type McpToolResult } from \"./results.js\";\n\nexport const TOOL_NAMES = [\n \"tinycloud_status\",\n \"tinycloud_auth_status\",\n \"tinycloud_auth_capabilities\",\n \"tinycloud_auth_request\",\n \"tinycloud_auth_import\",\n \"tinycloud_account_spaces_list\",\n \"tinycloud_account_applications_list\",\n \"tinycloud_kv_list\",\n \"tinycloud_kv_get\",\n \"tinycloud_secrets_get\",\n] as const;\n\nexport type ToolName = (typeof TOOL_NAMES)[number];\n\nexport interface McpStartupSelection {\n readonly profile: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n}\n\nexport interface McpInvocationTarget {\n readonly profile: string;\n readonly allowOwnerProfile?: true;\n}\n\n/** Project one startup selection into the only owner-sensitive target shape. */\nexport function invocationTargetForMcp(\n selection: McpStartupSelection,\n): McpInvocationTarget {\n return {\n profile: selection.profile,\n ...(selection.explicitProfile && selection.allowOwnerProfile\n ? { allowOwnerProfile: true }\n : {}),\n };\n}\n\ninterface CatalogOperation {\n readonly id: string;\n readonly version: number;\n readonly title: string;\n readonly description: string;\n readonly input: Record<string, unknown>;\n readonly result: Record<string, unknown>;\n}\n\ninterface OperationsCatalog {\n readonly operations: readonly CatalogOperation[];\n}\n\n// The require anchor is this module, never the consumer entrypoint. In ESM\n// tsup preserves import.meta.url; in CJS it rewrites the same module-relative\n// anchor to the generated __filename, so both formats stay in MCP's package\n// dependency boundary.\nconst packageRequire = createRequire(\n typeof __dirname === \"string\" ? join(__dirname, \"tools.cjs\") : import.meta.url,\n);\nconst generatedCatalog = packageRequire(\n \"@tinycloud/operations/operations.json\",\n) as OperationsCatalog;\n\ninterface ToolBinding {\n readonly name: ToolName;\n readonly operationId: string;\n readonly operationVersion: number;\n readonly readOnlyHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n}\n\nconst TOOL_BINDINGS: readonly ToolBinding[] = [\n {\n name: \"tinycloud_status\",\n operationId: \"tinycloud.status.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_status\",\n operationId: \"tinycloud.auth.status\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_capabilities\",\n operationId: \"tinycloud.auth.capabilities\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_request\",\n operationId: \"tinycloud.auth.request\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_import\",\n operationId: \"tinycloud.auth.import\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_account_spaces_list\",\n operationId: \"tinycloud.account.spaces.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_account_applications_list\",\n operationId: \"tinycloud.account.applications.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_list\",\n operationId: \"tinycloud.kv.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_get\",\n operationId: \"tinycloud.kv.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_secrets_get\",\n operationId: \"tinycloud.secrets.get\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: true,\n },\n] as const;\n\nexport function createJsonSchemaValidator(): AjvJsonSchemaValidator {\n const ajv = new Ajv({ strict: false });\n addFormats(ajv);\n return new AjvJsonSchemaValidator(ajv);\n}\n\nexport function registerTinyCloudTools(\n server: McpServer,\n selection: McpStartupSelection,\n validator: AjvJsonSchemaValidator,\n): void {\n const definitions = new Map(\n generatedCatalog.operations.map((operation) => [\n `${operation.id}@${operation.version}`,\n operation,\n ]),\n );\n\n for (const binding of TOOL_BINDINGS) {\n const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);\n if (operation === undefined) {\n throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);\n }\n\n const inputSchema = fromJsonSchema(\n operation.input as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const outputSchema = fromJsonSchema(\n operation.result as unknown as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const annotations: ToolAnnotations = {\n readOnlyHint: binding.readOnlyHint,\n idempotentHint: binding.idempotentHint,\n destructiveHint: false,\n openWorldHint: binding.openWorldHint,\n };\n\n server.registerTool(\n binding.name,\n {\n title: operation.title,\n description: operation.description,\n inputSchema,\n outputSchema,\n annotations,\n },\n async (input: unknown): Promise<McpToolResult> => {\n const result = await invokeOperation(\n binding.operationId,\n binding.operationVersion,\n invocationTargetForMcp(selection),\n input,\n );\n return toMcpToolResult(result);\n },\n );\n }\n}\n\nexport function toolBindingsForTest(): readonly ToolBinding[] {\n return TOOL_BINDINGS;\n}\n","/**\n * MCP has one structured result channel for a TinyCloud operation. Text is a\n * fixed, non-sensitive status line; it never serializes the operation result.\n */\nexport interface CanonicalOperationResult {\n readonly status: \"ok\" | \"authority_required\" | \"setup_required\" | \"error\";\n readonly [key: string]: unknown;\n}\n\nexport interface McpToolResult extends CallToolResult {\n readonly content: [{ readonly type: \"text\"; readonly text: string }];\n readonly structuredContent: CanonicalOperationResult;\n}\n\nexport function toMcpToolResult(result: unknown): McpToolResult {\n const canonical: CanonicalOperationResult = isCanonicalOperationResult(result)\n ? result\n : {\n status: \"error\",\n operation: {},\n context: {},\n error: { code: \"INTERNAL_ERROR\" },\n };\n\n return {\n content: [{ type: \"text\", text: resultSummary(canonical.status) }],\n structuredContent: canonical,\n };\n}\n\n/** The canonical envelope immediately before MCP protocol serialization. */\nexport function canonicalMcpAdapterResult(result: unknown): CanonicalOperationResult {\n return toMcpToolResult(result).structuredContent;\n}\n\nfunction isCanonicalOperationResult(value: unknown): value is CanonicalOperationResult {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const status = (value as { status?: unknown }).status;\n return status === \"ok\" ||\n status === \"authority_required\" ||\n status === \"setup_required\" ||\n status === \"error\";\n}\n\nfunction resultSummary(status: CanonicalOperationResult[\"status\"]): string {\n switch (status) {\n case \"ok\":\n return \"TinyCloud operation completed; use the structured result.\";\n case \"authority_required\":\n return \"TinyCloud authority is required; use the structured request and approval action.\";\n case \"setup_required\":\n return \"TinyCloud setup is required; use the structured setup action.\";\n case \"error\":\n return \"TinyCloud operation failed; use the structured error.\";\n }\n}\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n","{\n \"name\": \"@tinycloud/mcp\",\n \"version\": \"0.1.0-beta.2\",\n \"description\": \"TinyCloud delegated operations MCP server\",\n \"author\": \"TinyCloud, Inc.\",\n \"license\": \"EGPL\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"tinycloud-mcp\": \"./bin/tinycloud-mcp\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"types\": \"./dist/server.d.ts\",\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./tools\": {\n \"types\": \"./dist/tools.d.ts\",\n \"import\": \"./dist/tools.js\",\n \"require\": \"./dist/tools.cjs\"\n },\n \"./results\": {\n \"types\": \"./dist/results.d.ts\",\n \"import\": \"./dist/results.js\",\n \"require\": \"./dist/results.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"generated\",\n \"skills\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"bun run build && bun scripts/test.ts && bun run check:generated\",\n \"test:stdio\": \"bun run build && bun test src/stdio.test.ts\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"generate\": \"bun scripts/generate.ts\",\n \"check:generated\": \"bun scripts/generate.ts --check\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/server\": \"2.0.0-beta.4\",\n \"@tinycloud/operations\": \"0.1.0-beta.2\"\n },\n \"devDependencies\": {\n \"@modelcontextprotocol/client\": \"2.0.0-beta.4\",\n \"@types/node\": \"^20\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/tinycloudlabs/web-sdk\"\n }\n}\n","import packageMetadata from \"../package.json\";\n\nexport const MCP_VERSION =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AAGO,SAAS,kBAAkB,WAAmD;AACnF,SAAO;AAAA,IACL,MAAM,yBAAyB,SAAS;AAAA,IACxC,EAAE,SAAS,MAAM,uBAAuB,qBAAqB,EAAE;AAAA,EACjE;AACF;AAEA,SAAS,uBAAuB,SAAuB;AACrD,UAAQ,OAAO,MAAM,mBAAmB,OAAO;AAAA,CAAI;AACrD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/server.ts","../src/tools.ts","../src/results.ts","../package.json","../src/version.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/server\";\nimport { serveStdio, type StdioServerHandle } from \"@modelcontextprotocol/server/stdio\";\n\nimport { createJsonSchemaValidator, registerTinyCloudTools, type McpStartupSelection } from \"./tools.js\";\nimport { MCP_VERSION } from \"./version.js\";\n\nexport const MCP_SERVER_NAME = \"tinycloud-mcp\";\nexport { MCP_VERSION } from \"./version.js\";\nexport function createTinyCloudMcpServer(selection: McpStartupSelection): McpServer {\n const validator = createJsonSchemaValidator();\n const server = new McpServer(\n { name: MCP_SERVER_NAME, version: MCP_VERSION },\n { jsonSchemaValidator: validator },\n );\n registerTinyCloudTools(server, selection, validator);\n return server;\n}\n\n/** Start the only supported MCP transport: local stdio. */\nexport function serveTinyCloudMcp(selection: McpStartupSelection): StdioServerHandle {\n return serveStdio(\n () => createTinyCloudMcpServer(selection),\n { onerror: () => writeBoundedDiagnostic(\"MCP transport error\") },\n );\n}\n\nfunction writeBoundedDiagnostic(message: string): void {\n process.stderr.write(`[tinycloud-mcp] ${message}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\n\nimport { fromJsonSchema, type McpServer, type ToolAnnotations } from \"@modelcontextprotocol/server\";\nimport { addFormats, Ajv, AjvJsonSchemaValidator } from \"@modelcontextprotocol/server/validators/ajv\";\nimport { invokeOperation } from \"@tinycloud/operations\";\n\nimport { toMcpToolResult, type McpToolResult } from \"./results.js\";\n\nexport const TOOL_NAMES = [\n \"tinycloud_status\",\n \"tinycloud_auth_status\",\n \"tinycloud_auth_capabilities\",\n \"tinycloud_auth_request\",\n \"tinycloud_auth_import\",\n \"tinycloud_account_spaces_list\",\n \"tinycloud_account_applications_list\",\n \"tinycloud_kv_list\",\n \"tinycloud_kv_get\",\n \"tinycloud_secrets_get\",\n] as const;\n\nexport type ToolName = (typeof TOOL_NAMES)[number];\n\nexport interface McpStartupSelection {\n readonly profile: string;\n readonly explicitProfile: boolean;\n readonly allowOwnerProfile: boolean;\n}\n\nexport interface McpInvocationTarget {\n readonly profile: string;\n readonly allowOwnerProfile?: true;\n}\n\n/** Project one startup selection into the only owner-sensitive target shape. */\nexport function invocationTargetForMcp(\n selection: McpStartupSelection,\n): McpInvocationTarget {\n return {\n profile: selection.profile,\n ...(selection.explicitProfile && selection.allowOwnerProfile\n ? { allowOwnerProfile: true }\n : {}),\n };\n}\n\ninterface CatalogOperation {\n readonly id: string;\n readonly version: number;\n readonly title: string;\n readonly description: string;\n readonly input: Record<string, unknown>;\n readonly result: Record<string, unknown>;\n}\n\ninterface OperationsCatalog {\n readonly operations: readonly CatalogOperation[];\n}\n\n// The require anchor is this module, never the consumer entrypoint. In ESM\n// tsup preserves import.meta.url; in CJS it rewrites the same module-relative\n// anchor to the generated __filename, so both formats stay in MCP's package\n// dependency boundary.\nconst packageRequire = createRequire(\n typeof __dirname === \"string\" ? join(__dirname, \"tools.cjs\") : import.meta.url,\n);\nconst generatedCatalog = packageRequire(\n \"@tinycloud/operations/operations.json\",\n) as OperationsCatalog;\n\ninterface ToolBinding {\n readonly name: ToolName;\n readonly operationId: string;\n readonly operationVersion: number;\n readonly readOnlyHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n}\n\nconst TOOL_BINDINGS: readonly ToolBinding[] = [\n {\n name: \"tinycloud_status\",\n operationId: \"tinycloud.status.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_status\",\n operationId: \"tinycloud.auth.status\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_capabilities\",\n operationId: \"tinycloud.auth.capabilities\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_request\",\n operationId: \"tinycloud.auth.request\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_auth_import\",\n operationId: \"tinycloud.auth.import\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n {\n name: \"tinycloud_account_spaces_list\",\n operationId: \"tinycloud.account.spaces.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_account_applications_list\",\n operationId: \"tinycloud.account.applications.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_list\",\n operationId: \"tinycloud.kv.list\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_kv_get\",\n operationId: \"tinycloud.kv.get\",\n operationVersion: 1,\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: true,\n },\n {\n name: \"tinycloud_secrets_get\",\n operationId: \"tinycloud.secrets.get\",\n operationVersion: 1,\n readOnlyHint: false,\n idempotentHint: true,\n openWorldHint: true,\n },\n] as const;\n\nexport function createJsonSchemaValidator(): AjvJsonSchemaValidator {\n const ajv = new Ajv({ strict: false });\n addFormats(ajv);\n return new AjvJsonSchemaValidator(ajv);\n}\n\nexport function registerTinyCloudTools(\n server: McpServer,\n selection: McpStartupSelection,\n validator: AjvJsonSchemaValidator,\n): void {\n const definitions = new Map(\n generatedCatalog.operations.map((operation) => [\n `${operation.id}@${operation.version}`,\n operation,\n ]),\n );\n\n for (const binding of TOOL_BINDINGS) {\n const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);\n if (operation === undefined) {\n throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);\n }\n\n const inputSchema = fromJsonSchema(\n operation.input as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const outputSchema = fromJsonSchema(\n operation.result as unknown as Parameters<typeof fromJsonSchema>[0],\n validator,\n );\n const annotations: ToolAnnotations = {\n readOnlyHint: binding.readOnlyHint,\n idempotentHint: binding.idempotentHint,\n destructiveHint: false,\n openWorldHint: binding.openWorldHint,\n };\n\n server.registerTool(\n binding.name,\n {\n title: operation.title,\n description: operation.description,\n inputSchema,\n outputSchema,\n annotations,\n },\n async (input: unknown): Promise<McpToolResult> => {\n const result = await invokeOperation(\n binding.operationId,\n binding.operationVersion,\n invocationTargetForMcp(selection),\n input,\n );\n return toMcpToolResult(result);\n },\n );\n }\n}\n\nexport function toolBindingsForTest(): readonly ToolBinding[] {\n return TOOL_BINDINGS;\n}\n","/**\n * MCP has one structured result channel for a TinyCloud operation. Text is a\n * fixed, non-sensitive status line; it never serializes the operation result.\n */\nexport interface CanonicalOperationResult {\n readonly status: \"ok\" | \"authority_required\" | \"setup_required\" | \"error\";\n readonly [key: string]: unknown;\n}\n\nexport interface McpToolResult extends CallToolResult {\n readonly content: [{ readonly type: \"text\"; readonly text: string }];\n readonly structuredContent: CanonicalOperationResult;\n}\n\nexport function toMcpToolResult(result: unknown): McpToolResult {\n const canonical: CanonicalOperationResult = isCanonicalOperationResult(result)\n ? result\n : {\n status: \"error\",\n operation: {},\n context: {},\n error: { code: \"INTERNAL_ERROR\" },\n };\n\n return {\n content: [{ type: \"text\", text: resultSummary(canonical.status) }],\n structuredContent: canonical,\n };\n}\n\n/** The canonical envelope immediately before MCP protocol serialization. */\nexport function canonicalMcpAdapterResult(result: unknown): CanonicalOperationResult {\n return toMcpToolResult(result).structuredContent;\n}\n\nfunction isCanonicalOperationResult(value: unknown): value is CanonicalOperationResult {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n const status = (value as { status?: unknown }).status;\n return status === \"ok\" ||\n status === \"authority_required\" ||\n status === \"setup_required\" ||\n status === \"error\";\n}\n\nfunction resultSummary(status: CanonicalOperationResult[\"status\"]): string {\n switch (status) {\n case \"ok\":\n return \"TinyCloud operation completed; use the structured result.\";\n case \"authority_required\":\n return \"TinyCloud authority is required; use the structured request and approval action.\";\n case \"setup_required\":\n return \"TinyCloud setup is required; use the structured setup action.\";\n case \"error\":\n return \"TinyCloud operation failed; use the structured error.\";\n }\n}\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n","{\n \"name\": \"@tinycloud/mcp\",\n \"version\": \"0.1.0\",\n \"description\": \"TinyCloud delegated operations MCP server\",\n \"author\": \"TinyCloud, Inc.\",\n \"license\": \"EGPL\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"tinycloud-mcp\": \"./bin/tinycloud-mcp\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"types\": \"./dist/server.d.ts\",\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./tools\": {\n \"types\": \"./dist/tools.d.ts\",\n \"import\": \"./dist/tools.js\",\n \"require\": \"./dist/tools.cjs\"\n },\n \"./results\": {\n \"types\": \"./dist/results.d.ts\",\n \"import\": \"./dist/results.js\",\n \"require\": \"./dist/results.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"generated\",\n \"skills\"\n ],\n \"engines\": {\n \"node\": \">=20\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"bun run build && bun scripts/test.ts && bun run check:generated\",\n \"test:stdio\": \"bun run build && bun test src/stdio.test.ts\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"generate\": \"bun scripts/generate.ts\",\n \"check:generated\": \"bun scripts/generate.ts --check\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/server\": \"2.0.0-beta.4\",\n \"@tinycloud/operations\": \"0.1.0\"\n },\n \"devDependencies\": {\n \"@modelcontextprotocol/client\": \"2.0.0-beta.4\",\n \"@types/node\": \"^20\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/tinycloudlabs/web-sdk\"\n }\n}\n","import packageMetadata from \"../package.json\";\n\nexport const MCP_VERSION = packageMetadata.version;\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,kBAA0C;;;ACDnD,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AAErB,SAAS,sBAA4D;AACrE,SAAS,YAAY,KAAK,8BAA8B;AACxD,SAAS,uBAAuB;;;ACSzB,SAAS,gBAAgB,QAAgC;AAC9D,QAAM,YAAsC,2BAA2B,MAAM,IACzE,SACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW,CAAC;AAAA,IACZ,SAAS,CAAC;AAAA,IACV,OAAO,EAAE,MAAM,iBAAiB;AAAA,EAClC;AAEF,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,cAAc,UAAU,MAAM,EAAE,CAAC;AAAA,IACjE,mBAAmB;AAAA,EACrB;AACF;AAOA,SAAS,2BAA2B,OAAmD;AACrF,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,SAAU,MAA+B;AAC/C,SAAO,WAAW,QAChB,WAAW,wBACX,WAAW,oBACX,WAAW;AACf;AAEA,SAAS,cAAc,QAAoD;AACzE,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,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AA,IAChC,eAAe;AAAA,IACf,MAAQ;AAAA,IACR,YAAc;AAAA,EAChB;AAAA,EACA,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AACF;;;ACjEO,IAAM,cAAc,gBAAgB;;;AJIpC,IAAM,kBAAkB;AAExB,SAAS,yBAAyB,WAA2C;AAClF,QAAM,YAAY,0BAA0B;AAC5C,QAAM,SAAS,IAAI;AAAA,IACjB,EAAE,MAAM,iBAAiB,SAAS,YAAY;AAAA,IAC9C,EAAE,qBAAqB,UAAU;AAAA,EACnC;AACA,yBAAuB,QAAQ,WAAW,SAAS;AACnD,SAAO;AACT;AAGO,SAAS,kBAAkB,WAAmD;AACnF,SAAO;AAAA,IACL,MAAM,yBAAyB,SAAS;AAAA,IACxC,EAAE,SAAS,MAAM,uBAAuB,qBAAqB,EAAE;AAAA,EACjE;AACF;AAEA,SAAS,uBAAuB,SAAuB;AACrD,UAAQ,OAAO,MAAM,mBAAmB,OAAO;AAAA,CAAI;AACrD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinycloud/mcp",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "TinyCloud delegated operations MCP server",
|
|
5
5
|
"author": "TinyCloud, Inc.",
|
|
6
6
|
"license": "EGPL",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@modelcontextprotocol/server": "2.0.0-beta.4",
|
|
56
|
-
"@tinycloud/operations": "0.1.0
|
|
56
|
+
"@tinycloud/operations": "0.1.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@modelcontextprotocol/client": "2.0.0-beta.4",
|