// C1K MCP endpoint with the official MCP TypeScript SDK, the way desktop // agents and IDEs connect (MCP-01 to MCP-03). // npm install @modelcontextprotocol/sdk // C1K_MCP_TOKEN=c1k_mcp_... C1K_ORG_ID=org_... node mcp.mjs import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'; const token = process.env.C1K_MCP_TOKEN; const org = process.env.C1K_ORG_ID; if (!token || !org) throw new Error('Set C1K_MCP_TOKEN and C1K_ORG_ID'); const client = new Client({ name: 'c1k-example', version: '1.0.0' }); await client.connect(new StreamableHTTPClientTransport(new URL(`https://c1k.me/mcp/${org}`), { requestInit: { headers: { Authorization: `Bearer ${token}` } }, })); console.log('connected to', client.getServerVersion().title); const { tools } = await client.listTools(); console.log('tools:', tools.map((tool) => tool.name).join(', ')); // The SDK checks structuredContent against each tool's outputSchema. const created = await client.callTool({ name: 'create_link', arguments: { destination_url: 'https://venture.example/launch', idempotency_key: `mcp-example-${Date.now()}` }, }); if (created.isError) throw new Error(created.content[0].text); console.log('created', created.structuredContent.link.short_url); const listed = await client.callTool({ name: 'list_links', arguments: { limit: 10 } }); for (const link of listed.structuredContent.links) console.log(link.short_url, '->', link.destination_url); await client.close();