From 379d27ff4f700868fea7c407e76f1550513fc1ab Mon Sep 17 00:00:00 2001 From: Anurag Date: Sat, 11 Jul 2026 14:42:04 +0530 Subject: [PATCH 1/5] feat(core): add listPins to Meshkit client Expose pin listing through kubo-rpc-client so callers (including MCP) use the same authenticated client path as upload, pin, and listKeys. --- packages/core/src/create-client.ts | 8 ++++++++ packages/core/src/meshkit.ts | 4 ++++ packages/core/src/types.ts | 6 ++++++ packages/core/test/create-client.test.ts | 20 +++++++++++++++++++- packages/core/test/helpers/mock-client.ts | 1 + packages/core/test/meshkit.test.ts | 23 +++++++++++++++++++++++ 6 files changed, 61 insertions(+), 1 deletion(-) diff --git a/packages/core/src/create-client.ts b/packages/core/src/create-client.ts index 391ce3f..c058fcf 100644 --- a/packages/core/src/create-client.ts +++ b/packages/core/src/create-client.ts @@ -100,6 +100,14 @@ export function createMeshkitClient(config: MeshkitConfig): MeshkitClient { return keys.map((key) => ({ id: key.id, name: key.name })); }, + async listPins(): Promise { + const cids = new Set(); + for await (const { cid } of ipfs.pin.ls({ type: 'all' })) { + cids.add(cid.toString()); + } + return [...cids]; + }, + async healthCheck(): Promise { await ipfs.id(); }, diff --git a/packages/core/src/meshkit.ts b/packages/core/src/meshkit.ts index c3319cc..1f18692 100644 --- a/packages/core/src/meshkit.ts +++ b/packages/core/src/meshkit.ts @@ -88,4 +88,8 @@ export class Meshkit implements MeshkitFacade { listKeys() { return withPrimary(this.clients, (client) => client.listKeys()); } + + listPins() { + return withPrimary(this.clients, (client) => client.listPins()); + } } diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 6a296bc..80b368b 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -81,6 +81,9 @@ export interface MeshkitClient { /** List keys in the node's keystore (includes `"self"`). */ listKeys(): Promise; + /** List all pinned CIDs on the connected node. */ + listPins(): Promise; + /** Confirm the node's RPC API is reachable. Throws if it is not. */ healthCheck(): Promise; } @@ -136,6 +139,9 @@ export interface Meshkit { /** List keys on the primary node's keystore. */ listKeys(): Promise; + /** List all pinned CIDs on the primary node. */ + listPins(): Promise; + /** Nodes that passed the health check at init, in priority order. */ readonly activeNodes: readonly string[]; } diff --git a/packages/core/test/create-client.test.ts b/packages/core/test/create-client.test.ts index 0ce42b9..2564f90 100644 --- a/packages/core/test/create-client.test.ts +++ b/packages/core/test/create-client.test.ts @@ -3,7 +3,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; const ipfs = { add: vi.fn(), cat: vi.fn(), - pin: { add: vi.fn() }, + pin: { add: vi.fn(), ls: vi.fn() }, id: vi.fn(), name: { publish: vi.fn(), @@ -115,6 +115,24 @@ describe('createMeshkitClient', () => { await expect(client.listKeys()).resolves.toEqual([{ id: 'k51Self', name: 'self' }]); }); + it('listPins collects streamed pin ls results', async () => { + async function* pins() { + yield { + cid: { toString: () => 'QmA' }, + type: 'recursive', + }; + yield { + cid: { toString: () => 'QmB' }, + type: 'recursive', + }; + } + ipfs.pin.ls.mockReturnValue(pins()); + + const client = createMeshkitClient({ apiUrl: 'http://127.0.0.1:5001' }); + await expect(client.listPins()).resolves.toEqual(['QmA', 'QmB']); + expect(ipfs.pin.ls).toHaveBeenCalledWith({ type: 'all' }); + }); + it('healthCheck calls ipfs.id()', async () => { ipfs.id.mockResolvedValue({}); diff --git a/packages/core/test/helpers/mock-client.ts b/packages/core/test/helpers/mock-client.ts index ab43889..3135821 100644 --- a/packages/core/test/helpers/mock-client.ts +++ b/packages/core/test/helpers/mock-client.ts @@ -15,6 +15,7 @@ export function createMockClient( resolveAndRetrieve: async () => new Uint8Array(), generateKey: async () => ({ name: 'self', id: 'QmSelf' }), listKeys: async () => [{ name: 'self', id: 'QmSelf' }], + listPins: async () => [], healthCheck: async () => undefined, ...overrides, }; diff --git a/packages/core/test/meshkit.test.ts b/packages/core/test/meshkit.test.ts index fc0384b..5d30b2e 100644 --- a/packages/core/test/meshkit.test.ts +++ b/packages/core/test/meshkit.test.ts @@ -222,4 +222,27 @@ describe('Meshkit operations', () => { expect(secondaryGenerate).not.toHaveBeenCalled(); expect(secondaryList).not.toHaveBeenCalled(); }); + + it('listPins uses primary node only', async () => { + const listPins = vi.fn(async () => ['QmA', 'QmB']); + const secondaryListPins = vi.fn(); + + vi.spyOn(health, 'filterHealthy').mockResolvedValue({ + clients: [ + createMockClient({ listPins }), + createMockClient({ listPins: secondaryListPins }), + ], + urls: ['http://primary:5001', 'http://secondary:5001'], + failed: [], + }); + + const mk = await Meshkit.init({ + nodes: ['http://primary:5001', 'http://secondary:5001'], + }); + + await expect(mk.listPins()).resolves.toEqual(['QmA', 'QmB']); + + expect(listPins).toHaveBeenCalledOnce(); + expect(secondaryListPins).not.toHaveBeenCalled(); + }); }); From a24e89a4452de411bb54ea25f0dffb2f82e96f1e Mon Sep 17 00:00:00 2001 From: Anurag Date: Sat, 11 Jul 2026 14:55:57 +0530 Subject: [PATCH 2/5] feat(mcp): scaffold MCP server package Add package metadata, build config, env parsing, Meshkit bootstrap, and stdio server entrypoint. --- packages/mcp/package.json | 49 +++++++++ packages/mcp/src/config.ts | 104 +++++++++++++++++++ packages/mcp/src/context.ts | 15 +++ packages/mcp/src/logger.ts | 11 ++ packages/mcp/src/main.ts | 47 +++++++++ packages/mcp/src/server.ts | 19 ++++ packages/mcp/test/config.test.ts | 162 ++++++++++++++++++++++++++++++ packages/mcp/test/context.test.ts | 21 ++++ packages/mcp/tsconfig.json | 13 +++ packages/mcp/tsup.config.ts | 20 ++++ 10 files changed, 461 insertions(+) create mode 100644 packages/mcp/package.json create mode 100644 packages/mcp/src/config.ts create mode 100644 packages/mcp/src/context.ts create mode 100644 packages/mcp/src/logger.ts create mode 100644 packages/mcp/src/main.ts create mode 100644 packages/mcp/src/server.ts create mode 100644 packages/mcp/test/config.test.ts create mode 100644 packages/mcp/test/context.test.ts create mode 100644 packages/mcp/tsconfig.json create mode 100644 packages/mcp/tsup.config.ts diff --git a/packages/mcp/package.json b/packages/mcp/package.json new file mode 100644 index 0000000..750a3fa --- /dev/null +++ b/packages/mcp/package.json @@ -0,0 +1,49 @@ +{ + "name": "@ipfs-meshkit/mcp", + "version": "1.0.0", + "description": "MCP server for IPFS Meshkit — upload, pin, retrieve, and IPNS tools for AI agents.", + "type": "module", + "bin": { + "meshkit-mcp": "./dist/main.js" + }, + "files": [ + "dist", + "README.md" + ], + "scripts": { + "build": "tsup", + "clean": "rm -rf dist", + "prepublishOnly": "npm run build" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/IPFS-Meshkit/meshkit0.git", + "directory": "packages/mcp" + }, + "keywords": [ + "ipfs", + "kubo", + "meshkit", + "mcp", + "model-context-protocol", + "ai" + ], + "author": "IPFS Meshkit Contributors", + "license": "MIT", + "engines": { + "node": ">=20" + }, + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@ipfs-meshkit/meshkit": "1.0.1", + "@modelcontextprotocol/sdk": "^1.29.0", + "zod": "^3.25.76" + }, + "devDependencies": { + "@types/node": "^25.9.3", + "tsup": "^8.5.0", + "typescript": "^6.0.3" + } +} diff --git a/packages/mcp/src/config.ts b/packages/mcp/src/config.ts new file mode 100644 index 0000000..bcf15b1 --- /dev/null +++ b/packages/mcp/src/config.ts @@ -0,0 +1,104 @@ +export interface McpConfig { + nodes: string[]; + headers?: Record | undefined; + /** Start or attach to a local Kubo daemon before connecting. */ + localNode: boolean; +} + +const DEFAULT_NODES = ['http://127.0.0.1:5001']; + +export function parseConfig(env: NodeJS.ProcessEnv = process.env): McpConfig { + const nodes = parseNodes(env.MESHKIT_NODES); + const headers = parseHeaders(env.MESHKIT_HEADERS); + const localNode = parseLocalNode(env.MESHKIT_LOCAL_NODE); + + return { + nodes, + localNode, + ...(headers !== undefined ? { headers } : {}), + }; +} + +function parseLocalNode(raw: string | undefined): boolean { + if (raw === undefined || raw.trim() === '') { + return false; + } + + switch (raw.trim().toLowerCase()) { + case '1': + case 'true': + case 'yes': + return true; + case '0': + case 'false': + case 'no': + return false; + default: + throw new Error( + 'MESHKIT_LOCAL_NODE must be true/false (or 1/0, yes/no)', + ); + } +} + +function parseNodes(raw: string | undefined): string[] { + if (raw === undefined || raw.trim() === '') { + return [...DEFAULT_NODES]; + } + + const nodes = raw + .split(',') + .map((node) => node.trim()) + .filter((node) => node.length > 0); + + if (nodes.length === 0) { + throw new Error('MESHKIT_NODES must contain at least one URL'); + } + + for (const node of nodes) { + validateNodeUrl(node); + } + + return nodes; +} + +function validateNodeUrl(node: string): void { + let url: URL; + try { + url = new URL(node); + } catch { + throw new Error(`Invalid node URL in MESHKIT_NODES: ${node}`); + } + + if (url.protocol !== 'http:' && url.protocol !== 'https:') { + throw new Error(`Node URL must use http or https: ${node}`); + } +} + +function parseHeaders( + raw: string | undefined, +): Record | undefined { + if (raw === undefined || raw.trim() === '') { + return undefined; + } + + let parsed: unknown; + try { + parsed = JSON.parse(raw); + } catch { + throw new Error('MESHKIT_HEADERS must be valid JSON'); + } + + if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) { + throw new Error('MESHKIT_HEADERS must be a JSON object'); + } + + const headers: Record = {}; + for (const [key, value] of Object.entries(parsed)) { + if (typeof value !== 'string') { + throw new Error(`MESHKIT_HEADERS value for "${key}" must be a string`); + } + headers[key] = value; + } + + return Object.keys(headers).length > 0 ? headers : undefined; +} diff --git a/packages/mcp/src/context.ts b/packages/mcp/src/context.ts new file mode 100644 index 0000000..77c8864 --- /dev/null +++ b/packages/mcp/src/context.ts @@ -0,0 +1,15 @@ +import type { Meshkit } from '@ipfs-meshkit/meshkit'; + +export interface MeshkitContext { + meshkit: Meshkit; + primaryNode: string; +} + +export function createContext(meshkit: Meshkit): MeshkitContext { + const primaryNode = meshkit.activeNodes[0]; + if (primaryNode === undefined) { + throw new Error('No active Meshkit nodes available'); + } + + return { meshkit, primaryNode }; +} diff --git a/packages/mcp/src/logger.ts b/packages/mcp/src/logger.ts new file mode 100644 index 0000000..f9c38e5 --- /dev/null +++ b/packages/mcp/src/logger.ts @@ -0,0 +1,11 @@ +export function logInfo(message: string): void { + console.error(`[meshkit-mcp] ${message}`); +} + +export function logError(message: string, error?: unknown): void { + if (error instanceof Error) { + console.error(`[meshkit-mcp] ${message}: ${error.message}`); + return; + } + console.error(`[meshkit-mcp] ${message}`); +} diff --git a/packages/mcp/src/main.ts b/packages/mcp/src/main.ts new file mode 100644 index 0000000..a3474af --- /dev/null +++ b/packages/mcp/src/main.ts @@ -0,0 +1,47 @@ +import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; +import { init, setupGracefulShutdown } from '@ipfs-meshkit/meshkit'; +import pkg from '../package.json' with { type: 'json' }; +import { parseConfig } from './config.js'; +import { createContext } from './context.js'; +import { logError, logInfo } from './logger.js'; +import { createServer } from './server.js'; + +async function main(): Promise { + const config = parseConfig(); + + if (config.localNode) { + logInfo('Local Kubo enabled — will start or attach to a daemon'); + } + + logInfo(`Connecting to nodes: ${config.nodes.join(', ')}`); + + const { meshkit, localNode } = await init({ + nodes: config.nodes, + ...(config.localNode ? { localNode: true } : {}), + ...(config.headers !== undefined ? { headers: config.headers } : {}), + }); + + if (localNode !== undefined) { + logInfo( + localNode.managed + ? `Started local Kubo at ${localNode.url}` + : `Attached to existing Kubo at ${localNode.url}`, + ); + setupGracefulShutdown(localNode); + } + + const ctx = createContext(meshkit); + + logInfo(`Active nodes: ${meshkit.activeNodes.join(', ')}`); + + const server = createServer(ctx, pkg.version); + const transport = new StdioServerTransport(); + await server.connect(transport); + + logInfo('Meshkit MCP server running on stdio'); +} + +main().catch((error: unknown) => { + logError('Fatal error', error); + process.exit(1); +}); diff --git a/packages/mcp/src/server.ts b/packages/mcp/src/server.ts new file mode 100644 index 0000000..5af0408 --- /dev/null +++ b/packages/mcp/src/server.ts @@ -0,0 +1,19 @@ +import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; +import type { MeshkitContext } from './context.js'; +import { registerIpnsTools } from './tools/ipns.js'; +import { registerStorageTools } from './tools/storage.js'; + +export function createServer( + ctx: MeshkitContext, + version: string, +): McpServer { + const server = new McpServer({ + name: 'meshkit', + version, + }); + + registerStorageTools(server, ctx); + registerIpnsTools(server, ctx); + + return server; +} diff --git a/packages/mcp/test/config.test.ts b/packages/mcp/test/config.test.ts new file mode 100644 index 0000000..41f3381 --- /dev/null +++ b/packages/mcp/test/config.test.ts @@ -0,0 +1,162 @@ +import { describe, expect, it } from 'vitest'; +import { parseConfig } from '../src/config.js'; + +describe('parseConfig', () => { + it('defaults to local Kubo when MESHKIT_NODES is unset', () => { + expect(parseConfig({})).toEqual({ + nodes: ['http://127.0.0.1:5001'], + localNode: false, + }); + }); + + it('parses comma-separated node URLs', () => { + expect( + parseConfig({ + MESHKIT_NODES: 'http://127.0.0.1:5001, https://backup.example.com:5001', + }), + ).toEqual({ + nodes: ['http://127.0.0.1:5001', 'https://backup.example.com:5001'], + localNode: false, + }); + }); + + it('parses optional auth headers from JSON', () => { + expect( + parseConfig({ + MESHKIT_NODES: 'http://127.0.0.1:5001', + MESHKIT_HEADERS: '{"Authorization":"Bearer token"}', + }), + ).toEqual({ + nodes: ['http://127.0.0.1:5001'], + headers: { Authorization: 'Bearer token' }, + localNode: false, + }); + }); + + it('rejects empty MESHKIT_NODES', () => { + expect(() => parseConfig({ MESHKIT_NODES: ' , ' })).toThrow( + /at least one URL/i, + ); + }); + + it('rejects invalid node URLs', () => { + expect(() => parseConfig({ MESHKIT_NODES: 'not-a-url' })).toThrow( + /Invalid node URL/i, + ); + }); + + it('rejects non-http(s) protocols', () => { + expect(() => parseConfig({ MESHKIT_NODES: 'ftp://127.0.0.1:5001' })).toThrow( + /http or https/i, + ); + }); + + it('rejects invalid MESHKIT_HEADERS JSON', () => { + expect(() => + parseConfig({ + MESHKIT_NODES: 'http://127.0.0.1:5001', + MESHKIT_HEADERS: '{bad json', + }), + ).toThrow(/valid JSON/i); + }); + + it('rejects non-object MESHKIT_HEADERS', () => { + expect(() => + parseConfig({ + MESHKIT_NODES: 'http://127.0.0.1:5001', + MESHKIT_HEADERS: '["not","object"]', + }), + ).toThrow(/JSON object/i); + }); + + it('rejects non-string header values', () => { + expect(() => + parseConfig({ + MESHKIT_NODES: 'http://127.0.0.1:5001', + MESHKIT_HEADERS: '{"count":1}', + }), + ).toThrow(/must be a string/i); + }); + + it('defaults when MESHKIT_NODES is whitespace only', () => { + expect(parseConfig({ MESHKIT_NODES: ' ' })).toEqual({ + nodes: ['http://127.0.0.1:5001'], + localNode: false, + }); + }); + + it('ignores trailing commas in MESHKIT_NODES', () => { + expect(parseConfig({ MESHKIT_NODES: 'http://127.0.0.1:5001,' })).toEqual({ + nodes: ['http://127.0.0.1:5001'], + localNode: false, + }); + }); + + it('accepts https node URLs', () => { + expect( + parseConfig({ MESHKIT_NODES: 'https://kubo.example.com:5001' }), + ).toEqual({ + nodes: ['https://kubo.example.com:5001'], + localNode: false, + }); + }); + + it('rejects ws:// node URLs', () => { + expect(() => + parseConfig({ MESHKIT_NODES: 'ws://127.0.0.1:5001' }), + ).toThrow(/http or https/i); + }); + + it('rejects null JSON for MESHKIT_HEADERS', () => { + expect(() => + parseConfig({ + MESHKIT_NODES: 'http://127.0.0.1:5001', + MESHKIT_HEADERS: 'null', + }), + ).toThrow(/JSON object/i); + }); + + it('treats empty header object as unset', () => { + expect( + parseConfig({ + MESHKIT_NODES: 'http://127.0.0.1:5001', + MESHKIT_HEADERS: '{}', + }), + ).toEqual({ + nodes: ['http://127.0.0.1:5001'], + localNode: false, + }); + }); + + it('ignores whitespace-only MESHKIT_HEADERS', () => { + expect( + parseConfig({ + MESHKIT_NODES: 'http://127.0.0.1:5001', + MESHKIT_HEADERS: ' ', + }), + ).toEqual({ + nodes: ['http://127.0.0.1:5001'], + localNode: false, + }); + }); + + it('enables local Kubo when MESHKIT_LOCAL_NODE is true', () => { + expect(parseConfig({ MESHKIT_LOCAL_NODE: 'true' })).toEqual({ + nodes: ['http://127.0.0.1:5001'], + localNode: true, + }); + }); + + it('accepts common truthy and falsy values for MESHKIT_LOCAL_NODE', () => { + expect(parseConfig({ MESHKIT_LOCAL_NODE: '1' }).localNode).toBe(true); + expect(parseConfig({ MESHKIT_LOCAL_NODE: 'yes' }).localNode).toBe(true); + expect(parseConfig({ MESHKIT_LOCAL_NODE: '0' }).localNode).toBe(false); + expect(parseConfig({ MESHKIT_LOCAL_NODE: 'no' }).localNode).toBe(false); + }); + + it('rejects invalid MESHKIT_LOCAL_NODE values', () => { + expect(() => parseConfig({ MESHKIT_LOCAL_NODE: 'maybe' })).toThrow( + /MESHKIT_LOCAL_NODE/i, + ); + }); +}); diff --git a/packages/mcp/test/context.test.ts b/packages/mcp/test/context.test.ts new file mode 100644 index 0000000..06e24ff --- /dev/null +++ b/packages/mcp/test/context.test.ts @@ -0,0 +1,21 @@ +import { describe, expect, it } from 'vitest'; +import { createContext } from '../src/context.js'; + +describe('createContext', () => { + it('uses the first active node as primaryNode', () => { + const meshkit = { + activeNodes: ['http://primary:5001', 'http://backup:5001'], + }; + + expect(createContext(meshkit as never)).toEqual({ + meshkit, + primaryNode: 'http://primary:5001', + }); + }); + + it('throws when no active nodes are available', () => { + expect(() => createContext({ activeNodes: [] } as never)).toThrow( + /No active Meshkit nodes/i, + ); + }); +}); diff --git a/packages/mcp/tsconfig.json b/packages/mcp/tsconfig.json new file mode 100644 index 0000000..bc5b9dc --- /dev/null +++ b/packages/mcp/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./dist", + "composite": true, + "types": ["node"] + }, + "include": ["src/**/*"], + "references": [ + { "path": "../meshkit" } + ] +} diff --git a/packages/mcp/tsup.config.ts b/packages/mcp/tsup.config.ts new file mode 100644 index 0000000..0ad11fd --- /dev/null +++ b/packages/mcp/tsup.config.ts @@ -0,0 +1,20 @@ +import { defineConfig } from 'tsup'; + +export default defineConfig({ + entry: ['src/main.ts'], + format: ['esm'], + outDir: 'dist', + clean: true, + sourcemap: true, + target: 'es2022', + dts: false, + banner: { + js: '#!/usr/bin/env node', + }, + external: [ + '@ipfs-meshkit/meshkit', + '@modelcontextprotocol/sdk', + 'zod', + 'kubo-rpc-client', + ], +}); From 8a07efcc6956d34504a5e54820e3335452a4e866 Mon Sep 17 00:00:00 2001 From: Anurag Date: Sat, 11 Jul 2026 14:57:47 +0530 Subject: [PATCH 3/5] feat(mcp): add storage and IPNS MCP tools Register upload, retrieve, pin, list_pins, publish, resolve, and key tools with Zod schemas, response formatting, and error handling. --- packages/mcp/src/format.ts | 54 ++++++++++ packages/mcp/src/schemas/ipns.ts | 37 +++++++ packages/mcp/src/schemas/storage.ts | 28 +++++ packages/mcp/src/tools/ipns.ts | 85 +++++++++++++++ packages/mcp/src/tools/run-tool.ts | 38 +++++++ packages/mcp/src/tools/storage.ts | 82 +++++++++++++++ packages/mcp/test/format.test.ts | 98 +++++++++++++++++ packages/mcp/test/tools/ipns.test.ts | 101 ++++++++++++++++++ packages/mcp/test/tools/run-tool.test.ts | 66 ++++++++++++ packages/mcp/test/tools/storage.test.ts | 127 +++++++++++++++++++++++ 10 files changed, 716 insertions(+) create mode 100644 packages/mcp/src/format.ts create mode 100644 packages/mcp/src/schemas/ipns.ts create mode 100644 packages/mcp/src/schemas/storage.ts create mode 100644 packages/mcp/src/tools/ipns.ts create mode 100644 packages/mcp/src/tools/run-tool.ts create mode 100644 packages/mcp/src/tools/storage.ts create mode 100644 packages/mcp/test/format.test.ts create mode 100644 packages/mcp/test/tools/ipns.test.ts create mode 100644 packages/mcp/test/tools/run-tool.test.ts create mode 100644 packages/mcp/test/tools/storage.test.ts diff --git a/packages/mcp/src/format.ts b/packages/mcp/src/format.ts new file mode 100644 index 0000000..ee05332 --- /dev/null +++ b/packages/mcp/src/format.ts @@ -0,0 +1,54 @@ +import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js'; + +export type ContentEncoding = 'text' | 'base64'; + +export interface EncodedContent { + content: string; + encoding: ContentEncoding; +} + +export interface UploadInput { + content?: string | undefined; + base64?: string | undefined; +} + +export function decodeUploadInput(input: UploadInput): Uint8Array { + if (input.base64 !== undefined) { + return Uint8Array.from(Buffer.from(input.base64, 'base64')); + } + + if (input.content !== undefined) { + return new TextEncoder().encode(input.content); + } + + throw new Error('Either content or base64 is required'); +} + +export function encodeRetrievedBytes(bytes: Uint8Array): EncodedContent { + const text = new TextDecoder('utf-8', { fatal: true }).decode(bytes); + return { content: text, encoding: 'text' }; +} + +export function encodeRetrievedBytesSafe(bytes: Uint8Array): EncodedContent { + try { + return encodeRetrievedBytes(bytes); + } catch { + return { + content: Buffer.from(bytes).toString('base64'), + encoding: 'base64', + }; + } +} + +export function textResult(data: unknown): CallToolResult { + return { + content: [{ type: 'text', text: JSON.stringify(data, null, 2) }], + }; +} + +export function errorResult(message: string): CallToolResult { + return { + isError: true, + content: [{ type: 'text', text: message }], + }; +} diff --git a/packages/mcp/src/schemas/ipns.ts b/packages/mcp/src/schemas/ipns.ts new file mode 100644 index 0000000..f3fcee7 --- /dev/null +++ b/packages/mcp/src/schemas/ipns.ts @@ -0,0 +1,37 @@ +import { z } from 'zod'; + +export const publishNameSchema = { + value: z + .string() + .describe('CID or /ipfs/... path to publish under IPNS'), + key: z + .string() + .optional() + .describe('Keystore label from ipfs_generate_key (default: node self key)'), + ttl: z + .string() + .optional() + .describe('Cache hint for resolvers, e.g. "1m", "1h"'), + lifetime: z + .string() + .optional() + .describe('Record validity window, e.g. "24h", "48h"'), +}; + +export const resolveSchema = { + name: z + .string() + .describe('IPNS name or /ipns/... path to resolve and retrieve'), +}; + +export const generateKeySchema = { + name: z.string().describe('Keystore label for the new IPNS key'), + type: z + .enum(['ed25519', 'rsa']) + .optional() + .describe('Key type (default: ed25519)'), +}; + +export type PublishNameInput = z.infer>; +export type ResolveInput = z.infer>; +export type GenerateKeyInput = z.infer>; diff --git a/packages/mcp/src/schemas/storage.ts b/packages/mcp/src/schemas/storage.ts new file mode 100644 index 0000000..4da74bf --- /dev/null +++ b/packages/mcp/src/schemas/storage.ts @@ -0,0 +1,28 @@ +import { z } from 'zod'; + +export const uploadSchema = z + .object({ + content: z + .string() + .optional() + .describe('UTF-8 text content to upload'), + base64: z + .string() + .optional() + .describe('Base64-encoded binary content to upload'), + }) + .refine((data) => data.content !== undefined || data.base64 !== undefined, { + message: 'Either content or base64 is required', + }); + +export const retrieveSchema = { + cid: z.string().describe('IPFS CID to retrieve'), +}; + +export const pinSchema = { + cid: z.string().describe('IPFS CID to pin'), +}; + +export type UploadInput = z.infer; +export type RetrieveInput = z.infer>; +export type PinInput = z.infer>; diff --git a/packages/mcp/src/tools/ipns.ts b/packages/mcp/src/tools/ipns.ts new file mode 100644 index 0000000..935c6a8 --- /dev/null +++ b/packages/mcp/src/tools/ipns.ts @@ -0,0 +1,85 @@ +import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; +import type { MeshkitContext } from '../context.js'; +import { encodeRetrievedBytesSafe, textResult } from '../format.js'; +import { + generateKeySchema, + publishNameSchema, + resolveSchema, + type GenerateKeyInput, + type PublishNameInput, + type ResolveInput, +} from '../schemas/ipns.js'; +import { runTool, runToolNoInput } from './run-tool.js'; + +export async function handlePublishName( + ctx: MeshkitContext, + input: PublishNameInput, +): Promise> { + const options = { + ...(input.key !== undefined ? { key: input.key } : {}), + ...(input.ttl !== undefined ? { ttl: input.ttl } : {}), + ...(input.lifetime !== undefined ? { lifetime: input.lifetime } : {}), + }; + + const result = await ctx.meshkit.publishName( + input.value, + Object.keys(options).length > 0 ? options : undefined, + ); + + return textResult({ name: result.name, value: result.value }); +} + +export async function handleResolve( + ctx: MeshkitContext, + input: ResolveInput, +): Promise> { + const bytes = await ctx.meshkit.resolveAndRetrieve(input.name); + const encoded = encodeRetrievedBytesSafe(bytes); + return textResult({ name: input.name, ...encoded }); +} + +export async function handleGenerateKey( + ctx: MeshkitContext, + input: GenerateKeyInput, +): Promise> { + const options = + input.type !== undefined ? { type: input.type } : undefined; + const key = await ctx.meshkit.generateKey(input.name, options); + return textResult({ id: key.id, name: key.name }); +} + +export async function handleListKeys( + ctx: MeshkitContext, +): Promise> { + const keys = await ctx.meshkit.listKeys(); + return textResult({ keys }); +} + +export function registerIpnsTools(server: McpServer, ctx: MeshkitContext): void { + server.tool( + 'ipfs_publish_name', + 'Publish an IPNS record pointing at a CID or /ipfs/... path', + publishNameSchema, + async (input) => runTool(ctx, handlePublishName, input), + ); + + server.tool( + 'ipfs_resolve', + 'Resolve an IPNS name and retrieve its content', + resolveSchema, + async (input) => runTool(ctx, handleResolve, input), + ); + + server.tool( + 'ipfs_generate_key', + 'Create a named IPNS signing key in the node keystore', + generateKeySchema, + async (input) => runTool(ctx, handleGenerateKey, input), + ); + + server.tool( + 'ipfs_list_keys', + 'List IPNS keys in the node keystore', + async () => runToolNoInput(ctx, handleListKeys), + ); +} diff --git a/packages/mcp/src/tools/run-tool.ts b/packages/mcp/src/tools/run-tool.ts new file mode 100644 index 0000000..c233c4b --- /dev/null +++ b/packages/mcp/src/tools/run-tool.ts @@ -0,0 +1,38 @@ +import { MeshkitError } from '@ipfs-meshkit/meshkit'; +import type { MeshkitContext } from '../context.js'; +import { errorResult, textResult } from '../format.js'; + +export async function runTool( + ctx: MeshkitContext, + handler: ( + context: MeshkitContext, + input: T, + ) => Promise>, + input: T, +): Promise> { + try { + return await handler(ctx, input); + } catch (error) { + return toToolError(error); + } +} + +export async function runToolNoInput( + ctx: MeshkitContext, + handler: ( + context: MeshkitContext, + ) => Promise>, +): Promise> { + try { + return await handler(ctx); + } catch (error) { + return toToolError(error); + } +} + +function toToolError(error: unknown): ReturnType { + if (error instanceof MeshkitError || error instanceof Error) { + return errorResult(error.message); + } + return errorResult('Unknown error'); +} diff --git a/packages/mcp/src/tools/storage.ts b/packages/mcp/src/tools/storage.ts new file mode 100644 index 0000000..71dc8d9 --- /dev/null +++ b/packages/mcp/src/tools/storage.ts @@ -0,0 +1,82 @@ +import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; +import type { MeshkitContext } from '../context.js'; +import { + decodeUploadInput, + encodeRetrievedBytesSafe, + textResult, + type UploadInput as RawUploadInput, +} from '../format.js'; +import { + pinSchema, + retrieveSchema, + uploadSchema, + type PinInput, + type RetrieveInput, + type UploadInput, +} from '../schemas/storage.js'; +import { runTool, runToolNoInput } from './run-tool.js'; + +export async function handleUpload( + ctx: MeshkitContext, + input: UploadInput, +): Promise> { + const bytes = decodeUploadInput(input as RawUploadInput); + const cid = await ctx.meshkit.upload(bytes); + return textResult({ cid }); +} + +export async function handleRetrieve( + ctx: MeshkitContext, + input: RetrieveInput, +): Promise> { + const bytes = await ctx.meshkit.retrieve(input.cid); + const encoded = encodeRetrievedBytesSafe(bytes); + return textResult({ cid: input.cid, ...encoded }); +} + +export async function handlePin( + ctx: MeshkitContext, + input: PinInput, +): Promise> { + await ctx.meshkit.pin(input.cid); + return textResult({ pinned: true, cid: input.cid }); +} + +export async function handleListPins( + ctx: MeshkitContext, +): Promise> { + const pins = await ctx.meshkit.listPins(); + return textResult({ pins }); +} + +export function registerStorageTools( + server: McpServer, + ctx: MeshkitContext, +): void { + server.tool( + 'ipfs_upload', + 'Upload content to IPFS and return the CID', + uploadSchema, + async (input) => runTool(ctx, handleUpload, input), + ); + + server.tool( + 'ipfs_retrieve', + 'Retrieve content from IPFS by CID', + retrieveSchema, + async (input) => runTool(ctx, handleRetrieve, input), + ); + + server.tool( + 'ipfs_pin', + 'Pin a CID on the connected IPFS node', + pinSchema, + async (input) => runTool(ctx, handlePin, input), + ); + + server.tool( + 'ipfs_list_pins', + 'List all pinned CIDs on the primary node', + async () => runToolNoInput(ctx, handleListPins), + ); +} diff --git a/packages/mcp/test/format.test.ts b/packages/mcp/test/format.test.ts new file mode 100644 index 0000000..040d5a1 --- /dev/null +++ b/packages/mcp/test/format.test.ts @@ -0,0 +1,98 @@ +import { describe, expect, it } from 'vitest'; +import { + decodeUploadInput, + encodeRetrievedBytes, + encodeRetrievedBytesSafe, + errorResult, + textResult, +} from '../src/format.js'; + +describe('decodeUploadInput', () => { + it('encodes text content as UTF-8 bytes', () => { + const bytes = decodeUploadInput({ content: 'hello' }); + expect(new TextDecoder().decode(bytes)).toBe('hello'); + }); + + it('decodes base64 content', () => { + const bytes = decodeUploadInput({ base64: 'aGVsbG8=' }); + expect(new TextDecoder().decode(bytes)).toBe('hello'); + }); + + it('prefers base64 when both are provided', () => { + const bytes = decodeUploadInput({ content: 'ignored', base64: 'aGVsbG8=' }); + expect(new TextDecoder().decode(bytes)).toBe('hello'); + }); + + it('throws when neither content nor base64 is provided', () => { + expect(() => decodeUploadInput({})).toThrow(/Either content or base64/i); + }); + + it('uploads empty text content', () => { + const bytes = decodeUploadInput({ content: '' }); + expect(bytes).toEqual(new Uint8Array()); + }); + + it('uploads empty base64 payload', () => { + const bytes = decodeUploadInput({ base64: '' }); + expect(bytes).toEqual(new Uint8Array()); + }); + + it('encodes unicode text as UTF-8', () => { + const bytes = decodeUploadInput({ content: 'hello 🌍' }); + expect(new TextDecoder().decode(bytes)).toBe('hello 🌍'); + }); +}); + +describe('encodeRetrievedBytes', () => { + it('returns text encoding for valid UTF-8', () => { + const bytes = new TextEncoder().encode('hello'); + expect(encodeRetrievedBytes(bytes)).toEqual({ + content: 'hello', + encoding: 'text', + }); + }); + + it('throws for invalid UTF-8', () => { + const bytes = Uint8Array.from([0xff, 0xfe, 0xfd]); + expect(() => encodeRetrievedBytes(bytes)).toThrow(); + }); +}); + +describe('encodeRetrievedBytesSafe', () => { + it('falls back to base64 for binary content', () => { + const bytes = Uint8Array.from([0xff, 0xfe, 0xfd]); + const result = encodeRetrievedBytesSafe(bytes); + expect(result.encoding).toBe('base64'); + expect(Buffer.from(result.content, 'base64')).toEqual(Buffer.from(bytes)); + }); + + it('returns text encoding for empty content', () => { + expect(encodeRetrievedBytesSafe(new Uint8Array())).toEqual({ + content: '', + encoding: 'text', + }); + }); + + it('preserves unicode in text encoding', () => { + const bytes = new TextEncoder().encode('café 🚀'); + expect(encodeRetrievedBytesSafe(bytes)).toEqual({ + content: 'café 🚀', + encoding: 'text', + }); + }); +}); + +describe('MCP result helpers', () => { + it('formats JSON text results', () => { + expect(textResult({ cid: 'QmTest' })).toEqual({ + content: [{ type: 'text', text: '{\n "cid": "QmTest"\n}' }], + }); + }); + + it('formats error results', () => { + expect(errorResult('upload failed')).toEqual({ + isError: true, + content: [{ type: 'text', text: 'upload failed' }], + }); + }); +}); diff --git a/packages/mcp/test/tools/ipns.test.ts b/packages/mcp/test/tools/ipns.test.ts new file mode 100644 index 0000000..83735ca --- /dev/null +++ b/packages/mcp/test/tools/ipns.test.ts @@ -0,0 +1,101 @@ +import { describe, expect, it, vi } from 'vitest'; +import type { MeshkitContext } from '../../src/context.js'; +import { + handleGenerateKey, + handleListKeys, + handlePublishName, + handleResolve, +} from '../../src/tools/ipns.js'; + +function createMockContext(): MeshkitContext { + return { + primaryNode: 'http://127.0.0.1:5001', + meshkit: { + activeNodes: ['http://127.0.0.1:5001'], + upload: vi.fn(), + retrieve: vi.fn(), + pin: vi.fn(), + publishName: vi + .fn() + .mockResolvedValue({ name: 'QmName', value: '/ipfs/QmValue' }), + resolveName: vi.fn(), + resolveAndRetrieve: vi + .fn() + .mockResolvedValue(new TextEncoder().encode('resolved')), + generateKey: vi.fn().mockResolvedValue({ id: 'QmKeyId', name: 'latest' }), + listKeys: vi + .fn() + .mockResolvedValue([{ id: 'QmSelf', name: 'self' }]), + listPins: vi.fn(), + }, + }; +} + +describe('IPNS tool handlers', () => { + it('handlePublishName publishes with optional fields', async () => { + const ctx = createMockContext(); + const result = await handlePublishName(ctx, { + value: 'QmValue', + key: 'latest', + ttl: '1m', + }); + + expect(ctx.meshkit.publishName).toHaveBeenCalledWith('QmValue', { + key: 'latest', + ttl: '1m', + }); + expect(result.content[0]?.text).toContain('QmName'); + }); + + it('handlePublishName omits options when only value is provided', async () => { + const ctx = createMockContext(); + await handlePublishName(ctx, { value: 'QmValue' }); + + expect(ctx.meshkit.publishName).toHaveBeenCalledWith('QmValue', undefined); + }); + + it('handlePublishName passes lifetime without other options', async () => { + const ctx = createMockContext(); + await handlePublishName(ctx, { value: 'QmValue', lifetime: '24h' }); + + expect(ctx.meshkit.publishName).toHaveBeenCalledWith('QmValue', { + lifetime: '24h', + }); + }); + + it('handleResolve retrieves resolved content', async () => { + const ctx = createMockContext(); + const result = await handleResolve(ctx, { name: '/ipns/QmName' }); + + expect(ctx.meshkit.resolveAndRetrieve).toHaveBeenCalledWith('/ipns/QmName'); + expect(result.content[0]?.text).toContain('resolved'); + }); + + it('handleGenerateKey creates a keystore entry', async () => { + const ctx = createMockContext(); + const result = await handleGenerateKey(ctx, { + name: 'weekly', + type: 'ed25519', + }); + + expect(ctx.meshkit.generateKey).toHaveBeenCalledWith('weekly', { + type: 'ed25519', + }); + expect(result.content[0]?.text).toContain('QmKeyId'); + }); + + it('handleGenerateKey omits options when type is not provided', async () => { + const ctx = createMockContext(); + await handleGenerateKey(ctx, { name: 'weekly' }); + + expect(ctx.meshkit.generateKey).toHaveBeenCalledWith('weekly', undefined); + }); + + it('handleListKeys returns keystore entries', async () => { + const ctx = createMockContext(); + const result = await handleListKeys(ctx); + + expect(ctx.meshkit.listKeys).toHaveBeenCalled(); + expect(result.content[0]?.text).toContain('QmSelf'); + }); +}); diff --git a/packages/mcp/test/tools/run-tool.test.ts b/packages/mcp/test/tools/run-tool.test.ts new file mode 100644 index 0000000..70039cf --- /dev/null +++ b/packages/mcp/test/tools/run-tool.test.ts @@ -0,0 +1,66 @@ +import { describe, expect, it, vi } from 'vitest'; +import { MeshkitError } from '@ipfs-meshkit/meshkit'; +import type { MeshkitContext } from '../../src/context.js'; +import { runTool, runToolNoInput } from '../../src/tools/run-tool.js'; +import { handleUpload } from '../../src/tools/storage.js'; + +function createMockContext(): MeshkitContext { + return { + primaryNode: 'http://127.0.0.1:5001', + meshkit: { + activeNodes: ['http://127.0.0.1:5001'], + upload: vi.fn().mockResolvedValue('QmUpload'), + retrieve: vi.fn(), + pin: vi.fn(), + publishName: vi.fn(), + resolveName: vi.fn(), + resolveAndRetrieve: vi.fn(), + generateKey: vi.fn(), + listKeys: vi.fn(), + listPins: vi.fn(), + }, + }; +} + +describe('runTool', () => { + it('returns MCP error result for validation failures', async () => { + const ctx = createMockContext(); + const result = await runTool(ctx, handleUpload, {}); + + expect(result.isError).toBe(true); + expect(result.content[0]?.text).toMatch(/Either content or base64/i); + expect(ctx.meshkit.upload).not.toHaveBeenCalled(); + }); + + it('returns MCP error result for MeshkitError', async () => { + const ctx = createMockContext(); + vi.mocked(ctx.meshkit.upload).mockRejectedValue( + new MeshkitError('No reachable nodes'), + ); + + const result = await runTool(ctx, handleUpload, { content: 'hello' }); + + expect(result.isError).toBe(true); + expect(result.content[0]?.text).toContain('No reachable nodes'); + }); + + it('returns MCP error result for generic errors', async () => { + const ctx = createMockContext(); + vi.mocked(ctx.meshkit.upload).mockRejectedValue(new Error('network down')); + + const result = await runTool(ctx, handleUpload, { content: 'hello' }); + + expect(result.isError).toBe(true); + expect(result.content[0]?.text).toBe('network down'); + }); + + it('returns unknown error for non-Error throws', async () => { + const ctx = createMockContext(); + const result = await runToolNoInput(ctx, async () => { + throw 'boom'; + }); + + expect(result.isError).toBe(true); + expect(result.content[0]?.text).toBe('Unknown error'); + }); +}); diff --git a/packages/mcp/test/tools/storage.test.ts b/packages/mcp/test/tools/storage.test.ts new file mode 100644 index 0000000..df2c8ba --- /dev/null +++ b/packages/mcp/test/tools/storage.test.ts @@ -0,0 +1,127 @@ +import { describe, expect, it, vi } from 'vitest'; +import { MeshkitError } from '@ipfs-meshkit/meshkit'; +import type { MeshkitContext } from '../../src/context.js'; +import { uploadSchema } from '../../src/schemas/storage.js'; +import { + handleListPins, + handlePin, + handleRetrieve, + handleUpload, +} from '../../src/tools/storage.js'; + +function createMockContext(): MeshkitContext { + return { + primaryNode: 'http://127.0.0.1:5001', + meshkit: { + activeNodes: ['http://127.0.0.1:5001'], + upload: vi.fn().mockResolvedValue('QmUpload'), + retrieve: vi.fn().mockResolvedValue(new TextEncoder().encode('hello')), + pin: vi.fn().mockResolvedValue(undefined), + publishName: vi.fn(), + resolveName: vi.fn(), + resolveAndRetrieve: vi.fn(), + generateKey: vi.fn(), + listKeys: vi.fn(), + listPins: vi.fn().mockResolvedValue(['QmA', 'QmB']), + }, + }; +} + +describe('storage tool handlers', () => { + it('handleUpload uploads UTF-8 content and returns CID', async () => { + const ctx = createMockContext(); + const result = await handleUpload(ctx, { content: 'hello' }); + + expect(ctx.meshkit.upload).toHaveBeenCalledWith( + new TextEncoder().encode('hello'), + ); + expect(result.content[0]?.text).toContain('QmUpload'); + }); + + it('handleRetrieve returns text-encoded content', async () => { + const ctx = createMockContext(); + const result = await handleRetrieve(ctx, { cid: 'QmTest' }); + + expect(ctx.meshkit.retrieve).toHaveBeenCalledWith('QmTest'); + expect(result.content[0]?.text).toContain('"encoding": "text"'); + expect(result.content[0]?.text).toContain('hello'); + }); + + it('handlePin pins a CID', async () => { + const ctx = createMockContext(); + const result = await handlePin(ctx, { cid: 'QmPin' }); + + expect(ctx.meshkit.pin).toHaveBeenCalledWith('QmPin'); + expect(result.content[0]?.text).toContain('"pinned": true'); + }); + + it('handleListPins lists pins from the primary node via meshkit', async () => { + const ctx = createMockContext(); + + const result = await handleListPins(ctx); + + expect(ctx.meshkit.listPins).toHaveBeenCalled(); + expect(result.content[0]?.text).toContain('QmA'); + expect(result.content[0]?.text).toContain('QmB'); + }); + + it('handleUpload surfaces MeshkitError messages', async () => { + const ctx = createMockContext(); + vi.mocked(ctx.meshkit.upload).mockRejectedValue( + new MeshkitError('No reachable nodes'), + ); + + await expect(handleUpload(ctx, { content: 'x' })).rejects.toThrow( + /No reachable nodes/i, + ); + }); + + it('handleUpload accepts base64 input', async () => { + const ctx = createMockContext(); + await handleUpload(ctx, { base64: 'aGVsbG8=' }); + + expect(ctx.meshkit.upload).toHaveBeenCalledWith( + new TextEncoder().encode('hello'), + ); + }); + + it('handleRetrieve returns base64 for binary content', async () => { + const ctx = createMockContext(); + vi.mocked(ctx.meshkit.retrieve).mockResolvedValue( + Uint8Array.from([0xff, 0xfe]), + ); + + const result = await handleRetrieve(ctx, { cid: 'QmBinary' }); + + expect(result.content[0]?.text).toContain('"encoding": "base64"'); + }); + + it('handleListPins returns an empty array', async () => { + const ctx = createMockContext(); + vi.mocked(ctx.meshkit.listPins).mockResolvedValue([]); + + const result = await handleListPins(ctx); + + expect(result.content[0]?.text).toContain('"pins": []'); + }); +}); + +describe('uploadSchema', () => { + it('rejects empty input', () => { + const result = uploadSchema.safeParse({}); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0]?.message).toMatch( + /Either content or base64/i, + ); + } + }); + + it('accepts text content', () => { + expect(uploadSchema.safeParse({ content: 'hello' }).success).toBe(true); + }); + + it('accepts base64 content', () => { + expect(uploadSchema.safeParse({ base64: 'aGVsbG8=' }).success).toBe(true); + }); +}); From b0417948ff5a4a8bf57bbbb5f87499a9a234acab Mon Sep 17 00:00:00 2001 From: Anurag Date: Sat, 11 Jul 2026 15:00:21 +0530 Subject: [PATCH 4/5] feat(mcp): document setup and add local Kubo auto-start --- packages/mcp/README.md | 150 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 packages/mcp/README.md diff --git a/packages/mcp/README.md b/packages/mcp/README.md new file mode 100644 index 0000000..d697d1f --- /dev/null +++ b/packages/mcp/README.md @@ -0,0 +1,150 @@ +# @ipfs-meshkit/mcp + +MCP (Model Context Protocol) server for [IPFS Meshkit](https://github.com/IPFS-Meshkit/meshkit0). Exposes Kubo storage and IPNS operations as tools for AI agents in Cursor, Claude Desktop, and other MCP clients. + +## Prerequisites + +- **Node.js 20+** +- A running [Kubo](https://docs.ipfs.tech/install/) node with RPC API reachable (default: `http://127.0.0.1:5001`), **or** set `MESHKIT_LOCAL_NODE=true` to start/attach to Kubo automatically (requires `ipfs` on `PATH`) + +## Quick start + +```bash +npx -y @ipfs-meshkit/mcp +``` + +Or install globally: + +```bash +npm install -g @ipfs-meshkit/mcp +meshkit-mcp +``` + +## Configuration + +Set environment variables in your MCP client config: + +| Variable | Default | Description | +|----------|---------|-------------| +| `MESHKIT_NODES` | `http://127.0.0.1:5001` | Comma-separated Kubo RPC URLs | +| `MESHKIT_HEADERS` | — | Optional JSON object for RPC auth headers | +| `MESHKIT_LOCAL_NODE` | `false` | Start or attach to a local Kubo daemon (`true`/`1`/`yes`) | + +### Cursor + +Add to your MCP settings (`mcp.json`): + +```json +{ + "mcpServers": { + "meshkit": { + "command": "npx", + "args": ["-y", "@ipfs-meshkit/mcp"], + "env": { + "MESHKIT_LOCAL_NODE": "true" + } + } + } +} +``` + +If you already run Kubo yourself, omit `MESHKIT_LOCAL_NODE` or set it to `false` and point `MESHKIT_NODES` at your RPC URL. + +### Claude Desktop + +Add to `claude_desktop_config.json`: + +```json +{ + "mcpServers": { + "meshkit": { + "command": "npx", + "args": ["-y", "@ipfs-meshkit/mcp"], + "env": { + "MESHKIT_NODES": "http://127.0.0.1:5001" + } + } + } +} +``` + +### Remote or authenticated Kubo + +```json +{ + "mcpServers": { + "meshkit": { + "command": "npx", + "args": ["-y", "@ipfs-meshkit/mcp"], + "env": { + "MESHKIT_NODES": "https://kubo.example.com:5001", + "MESHKIT_HEADERS": "{\"Authorization\":\"Bearer YOUR_TOKEN\"}" + } + } + } +} +``` + +## Tools + +| Tool | Description | +|------|-------------| +| `ipfs_upload` | Upload text or base64 content; returns CID | +| `ipfs_retrieve` | Retrieve content by CID | +| `ipfs_pin` | Pin a CID on the node | +| `ipfs_list_pins` | List all pinned CIDs on the primary node | +| `ipfs_publish_name` | Publish an IPNS record | +| `ipfs_resolve` | Resolve an IPNS name and retrieve content | +| `ipfs_generate_key` | Create a named IPNS signing key | +| `ipfs_list_keys` | List IPNS keys in the keystore | + +### Examples + +**Upload text:** + +```json +{ "content": "Hello, IPFS!" } +``` + +**Upload binary:** + +```json +{ "base64": "aGVsbG8=" } +``` + +**Retrieve:** + +```json +{ "cid": "Qm..." } +``` + +**Publish to IPNS:** + +```json +{ + "value": "Qm...", + "key": "latest", + "ttl": "1m" +} +``` + +## How it works + +The MCP server connects to your Kubo node(s) at startup via [`@ipfs-meshkit/meshkit`](https://www.npmjs.com/package/@ipfs-meshkit/meshkit). AI clients communicate over **stdio** (stdin/stdout JSON-RPC). Logs go to stderr only. + +``` +AI client → stdio → @ipfs-meshkit/mcp → Meshkit → Kubo RPC +``` + +## Development + +From the monorepo root: + +```bash +npm run build:mcp +npm run test:unit -- --project unit packages/mcp +``` + +## License + +MIT From f904b86b31ccc57df7874d2f3f8ff197528ce619 Mon Sep 17 00:00:00 2001 From: Anurag Date: Sat, 11 Jul 2026 15:00:49 +0530 Subject: [PATCH 5/5] chore: wire MCP package into monorepo build and CI --- .github/workflows/test.yml | 1 + package-lock.json | 995 ++++++++++++++++++++++++++++++++++++- package.json | 1 + tsconfig.json | 1 + vitest.config.ts | 1 + 5 files changed, 976 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a41bea8..09a5c41 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,4 +18,5 @@ jobs: - run: npm ci - run: npm run build + - run: npm run build:mcp - run: npm run test:ci diff --git a/package-lock.json b/package-lock.json index e533a47..0027ecf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ipfs-meshkit/meshkit", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@ipfs-meshkit/meshkit", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "workspaces": [ "packages/*", @@ -794,6 +794,18 @@ "node": ">=18" } }, + "node_modules/@hono/node-server": { + "version": "1.19.14", + "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.19.14.tgz", + "integrity": "sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw==", + "license": "MIT", + "engines": { + "node": ">=18.14.1" + }, + "peerDependencies": { + "hono": "^4" + } + }, "node_modules/@ipfs-meshkit/capacitor": { "resolved": "packages/capacitor", "link": true @@ -802,6 +814,10 @@ "resolved": "packages/core", "link": true }, + "node_modules/@ipfs-meshkit/mcp": { + "resolved": "packages/mcp", + "link": true + }, "node_modules/@ipfs-meshkit/meshkit": { "resolved": "", "link": true @@ -1122,6 +1138,46 @@ "uint8arrays": "^6.1.1" } }, + "node_modules/@modelcontextprotocol/sdk": { + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.29.0.tgz", + "integrity": "sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==", + "license": "MIT", + "dependencies": { + "@hono/node-server": "^1.19.9", + "ajv": "^8.17.1", + "ajv-formats": "^3.0.1", + "content-type": "^1.0.5", + "cors": "^2.8.5", + "cross-spawn": "^7.0.5", + "eventsource": "^3.0.2", + "eventsource-parser": "^3.0.0", + "express": "^5.2.1", + "express-rate-limit": "^8.2.1", + "hono": "^4.11.4", + "jose": "^6.1.3", + "json-schema-typed": "^8.0.2", + "pkce-challenge": "^5.0.0", + "raw-body": "^3.0.0", + "zod": "^3.25 || ^4.0", + "zod-to-json-schema": "^3.25.1" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@cfworker/json-schema": "^4.1.1", + "zod": "^3.25 || ^4.0" + }, + "peerDependenciesMeta": { + "@cfworker/json-schema": { + "optional": true + }, + "zod": { + "optional": false + } + } + }, "node_modules/@multiformats/dns": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/@multiformats/dns/-/dns-1.0.13.tgz", @@ -2010,7 +2066,6 @@ "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", "license": "MIT", - "peer": true, "dependencies": { "mime-types": "^3.0.0", "negotiator": "^1.0.0" @@ -2041,6 +2096,39 @@ "node": ">= 14" } }, + "node_modules/ajv": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, "node_modules/anser": { "version": "1.4.10", "resolved": "https://registry.npmjs.org/anser/-/anser-1.4.10.tgz", @@ -2187,6 +2275,71 @@ "browser-readablestream-to-it": "^2.0.0" } }, + "node_modules/body-parser": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz", + "integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^2.0.0", + "debug": "^4.4.3", + "http-errors": "^2.0.1", + "iconv-lite": "^0.7.2", + "on-finished": "^2.4.1", + "qs": "^6.15.2", + "raw-body": "^3.0.2", + "type-is": "^2.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/body-parser/node_modules/content-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz", + "integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/body-parser/node_modules/iconv-lite": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/body-parser/node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/brace-expansion": { "version": "5.0.7", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.7.tgz", @@ -2309,6 +2462,15 @@ "esbuild": ">=0.18" } }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -2319,6 +2481,35 @@ "node": ">=8" } }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/camelcase": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", @@ -2568,6 +2759,28 @@ "node": "^14.18.0 || >=16.10.0" } }, + "node_modules/content-disposition": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", + "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -2575,6 +2788,41 @@ "license": "MIT", "peer": true }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/cors": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", + "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -2653,7 +2901,6 @@ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", "license": "MIT", - "peer": true, "engines": { "node": ">= 0.8" } @@ -2669,6 +2916,20 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -2680,8 +2941,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/electron-fetch": { "version": "1.9.1", @@ -2743,6 +3003,24 @@ "stackframe": "^1.3.4" } }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/es-module-lexer": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", @@ -2750,6 +3028,18 @@ "dev": true, "license": "MIT" }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/esbuild": { "version": "0.28.1", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.1.tgz", @@ -2806,8 +3096,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/escape-string-regexp": { "version": "4.0.0", @@ -2837,7 +3126,6 @@ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", "license": "MIT", - "peer": true, "engines": { "node": ">= 0.6" } @@ -2858,6 +3146,27 @@ "integrity": "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==", "license": "MIT" }, + "node_modules/eventsource": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", + "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", + "license": "MIT", + "dependencies": { + "eventsource-parser": "^3.0.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/eventsource-parser": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.1.0.tgz", + "integrity": "sha512-kJezFj9YFAMLeORyi7aCLxLbD5/qWMQnoMVlVPyHIll7lgRJCc3JVln9Vgl9nwQi0YkMnhdGTMNn7CkRRAptMg==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/expect-type": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", @@ -2875,6 +3184,178 @@ "license": "Apache-2.0", "peer": true }, + "node_modules/express": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express-rate-limit": { + "version": "8.5.2", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.5.2.tgz", + "integrity": "sha512-5Kb34ipNX694DH48vN9irak1Qx30nb0PLYHXfJgw4YEjiC3ZEmZJhwOp+VfiCYwFzvFTdB9QkArYS5kXa2cx2A==", + "license": "MIT", + "dependencies": { + "ip-address": "^10.2.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/express-rate-limit" + }, + "peerDependencies": { + "express": ">= 4.11" + } + }, + "node_modules/express/node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/express/node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express/node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/express/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/express/node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/express/node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express/node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express/node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/fast-base64-decode": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fast-base64-decode/-/fast-base64-decode-1.0.0.tgz", @@ -2882,6 +3363,12 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" + }, "node_modules/fast-fifo": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", @@ -2911,6 +3398,22 @@ "dev": true, "license": "Apache-2.0" }, + "node_modules/fast-uri": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.3.tgz", + "integrity": "sha512-i70LwGWUduXqzicKXWshooq+sWL1K3WUU5rKZNG/0i3a1OSoX3HqhH5WbWwTmqWfor4urUakGPiRQcleRZTwOg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/fastq": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz", @@ -3027,6 +3530,15 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", @@ -3052,6 +3564,15 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -3072,12 +3593,49 @@ "node": "6.* || 8.* || >= 10.*" } }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/get-iterator": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/get-iterator/-/get-iterator-1.0.2.tgz", "integrity": "sha512-v+dm9bNVfOYsY1OrhaCrmyOcYoSeVvbt+hHZ0Au+T+p1y+0Uyj9aMaGIeUTT6xdpRbWzDeYKvfOslPhggQMcsg==", "license": "MIT" }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/glob": { "version": "10.5.0", "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", @@ -3139,10 +3697,22 @@ "brace-expansion": "^2.0.2" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" }, "funding": { - "url": "https://github.com/sponsors/isaacs" + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/graceful-fs": { @@ -3161,12 +3731,36 @@ "node": ">=8" } }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/hashlru": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/hashlru/-/hashlru-2.3.0.tgz", "integrity": "sha512-0cMsjjIC8I+D3M44pOQdsy0OHXGLVz6Z0beRuufhKa0KfaD2wGwAev6jILzXsd3/vpnNQJmWyZtIILqM1N+n5A==", "license": "MIT" }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/hermes-compiler": { "version": "250829098.0.14", "resolved": "https://registry.npmjs.org/hermes-compiler/-/hermes-compiler-250829098.0.14.tgz", @@ -3191,6 +3785,15 @@ "hermes-estree": "0.36.0" } }, + "node_modules/hono": { + "version": "4.12.29", + "resolved": "https://registry.npmjs.org/hono/-/hono-4.12.29.tgz", + "integrity": "sha512-1hNiRjawYrLq/4m3DQQjPGFg0VZkk4RjQJDff/excI6Dm9BiL75qxGrd7/c6YOxPdq6AscP3LiXhQ6fKFC1Waw==", + "license": "MIT", + "engines": { + "node": ">=16.9.0" + } + }, "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -3203,7 +3806,6 @@ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", "license": "MIT", - "peer": true, "dependencies": { "depd": "~2.0.0", "inherits": "~2.0.4", @@ -3224,7 +3826,6 @@ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", "license": "MIT", - "peer": true, "engines": { "node": ">= 0.8" } @@ -3338,6 +3939,24 @@ "loose-envify": "^1.0.0" } }, + "node_modules/ip-address": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.2.0.tgz", + "integrity": "sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/ipfs-unixfs": { "version": "13.0.0", "resolved": "https://registry.npmjs.org/ipfs-unixfs/-/ipfs-unixfs-13.0.0.tgz", @@ -3438,6 +4057,12 @@ "node": ">=8" } }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, "node_modules/is-wsl": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", @@ -3705,6 +4330,15 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "node_modules/jose": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.3.tgz", + "integrity": "sha512-YYVDInQKFJfR/xa3ojUTl8c2KoTwiL1R5Wg9YCydwH0x0B9grbzlg5HC7mMjCtUJjbQ/YnGEZIhI5tCgfTb4Hw==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, "node_modules/joycon": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", @@ -3742,6 +4376,18 @@ "node": ">=6" } }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "license": "MIT" + }, + "node_modules/json-schema-typed": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/json-schema-typed/-/json-schema-typed-8.0.2.tgz", + "integrity": "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==", + "license": "BSD-2-Clause" + }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -3960,6 +4606,24 @@ "license": "Apache-2.0", "peer": true }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/memoize-one": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.2.1.tgz", @@ -3967,6 +4631,18 @@ "license": "MIT", "peer": true }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/merge-options": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/merge-options/-/merge-options-3.0.4.tgz", @@ -4346,7 +5022,6 @@ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", "license": "MIT", - "peer": true, "engines": { "node": ">= 0.6" } @@ -4356,7 +5031,6 @@ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", "license": "MIT", - "peer": true, "dependencies": { "mime-db": "^1.54.0" }, @@ -4470,7 +5144,6 @@ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", "license": "MIT", - "peer": true, "engines": { "node": ">= 0.6" } @@ -4516,12 +5189,23 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" } }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -4535,6 +5219,15 @@ "node": ">= 0.8" } }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/open": { "version": "7.4.2", "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", @@ -4617,7 +5310,6 @@ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "license": "MIT", - "peer": true, "engines": { "node": ">= 0.8" } @@ -4655,6 +5347,16 @@ "dev": true, "license": "ISC" }, + "node_modules/path-to-regexp": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/pathe": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", @@ -4700,6 +5402,15 @@ "node": ">= 6" } }, + "node_modules/pkce-challenge": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.1.tgz", + "integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==", + "license": "MIT", + "engines": { + "node": ">=16.20.0" + } + }, "node_modules/pkg-types": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.3.1.tgz", @@ -4883,6 +5594,19 @@ "multiformats": "^13.0.0" } }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -4893,6 +5617,22 @@ "node": ">=6" } }, + "node_modules/qs": { + "version": "6.15.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.3.tgz", + "integrity": "sha512-O9gl3zCl5h5blw1KGUzQKhA5oUXSl8rwUIM5o0S3nCXMliSvy5Dzx7/DJcI+SwgICv+IneSZwhBh1oSyEHA71A==", + "license": "BSD-3-Clause", + "dependencies": { + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/queue": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/queue/-/queue-6.0.2.tgz", @@ -4928,11 +5668,41 @@ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", "license": "MIT", - "peer": true, "engines": { "node": ">= 0.6" } }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/raw-body/node_modules/iconv-lite": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/react": { "version": "19.2.7", "resolved": "https://registry.npmjs.org/react/-/react-19.2.7.tgz", @@ -5112,6 +5882,15 @@ "node": ">=0.10.0" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/resolve-from": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", @@ -5177,6 +5956,22 @@ "fsevents": "~2.3.2" } }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -5367,8 +6162,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "license": "ISC", - "peer": true + "license": "ISC" }, "node_modules/shebang-command": { "version": "2.0.0", @@ -5404,6 +6198,78 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/siginfo": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", @@ -5832,7 +6698,6 @@ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", "license": "MIT", - "peer": true, "engines": { "node": ">=0.6" } @@ -6418,6 +7283,37 @@ "node": ">=8" } }, + "node_modules/type-is": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", + "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", + "license": "MIT", + "dependencies": { + "content-type": "^2.0.0", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/type-is/node_modules/content-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz", + "integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/typescript": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", @@ -6502,7 +7398,6 @@ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", "license": "MIT", - "peer": true, "engines": { "node": ">= 0.8" } @@ -6560,6 +7455,15 @@ "node": ">= 0.4.0" } }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/vite": { "version": "7.3.6", "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.6.tgz", @@ -6956,6 +7860,12 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, "node_modules/ws": { "version": "7.5.11", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.11.tgz", @@ -7040,6 +7950,24 @@ "node": ">=12" } }, + "node_modules/zod": { + "version": "3.25.76", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", + "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zod-to-json-schema": { + "version": "3.25.2", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz", + "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==", + "license": "ISC", + "peerDependencies": { + "zod": "^3.25.28 || ^4" + } + }, "packages/capacitor": { "name": "@ipfs-meshkit/capacitor", "version": "1.0.0", @@ -7062,6 +7990,27 @@ "kubo-rpc-client": "^7.1.0" } }, + "packages/mcp": { + "name": "@ipfs-meshkit/mcp", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@ipfs-meshkit/meshkit": "1.0.1", + "@modelcontextprotocol/sdk": "^1.29.0", + "zod": "^3.25.76" + }, + "bin": { + "meshkit-mcp": "dist/main.js" + }, + "devDependencies": { + "@types/node": "^25.9.3", + "tsup": "^8.5.0", + "typescript": "^6.0.3" + }, + "engines": { + "node": ">=20" + } + }, "packages/meshkit": { "name": "@ipfs-meshkit/meshkit-workspace", "version": "1.0.0", diff --git a/package.json b/package.json index 62faa67..0f0519c 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ ], "scripts": { "build": "tsup", + "build:mcp": "npm run build && npm run build -w @ipfs-meshkit/mcp", "clean": "rm -rf dist && npm run clean --workspaces --if-present && find packages -name 'tsconfig.tsbuildinfo' -delete 2>/dev/null || true", "prepublishOnly": "npm run build", "test": "npm run test:unit", diff --git a/tsconfig.json b/tsconfig.json index 0910f1e..820852f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ { "path": "./packages/core" }, { "path": "./packages/node" }, { "path": "./packages/meshkit" }, + { "path": "./packages/mcp" }, { "path": "./packages/capacitor" }, { "path": "./packages/react-native" } ] diff --git a/vitest.config.ts b/vitest.config.ts index 31a6e2f..62d9157 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -8,6 +8,7 @@ const workspaceAliases = { '@ipfs-meshkit/core': path.join(root, 'packages/core/src/index.ts'), '@ipfs-meshkit/node': path.join(root, 'packages/node/src/index.ts'), '@ipfs-meshkit/meshkit': path.join(root, 'packages/meshkit/src/index.ts'), + '@ipfs-meshkit/mcp': path.join(root, 'packages/mcp/src/main.ts'), }; export default defineConfig({