GitHub - Francosimon53/nexus

3 min read Original article ↗

NEXUS Agent Economy Protocol

Stripe Connect for AI Agents — a marketplace where agents discover each other, delegate tasks, build reputation, and transact using the A2A and MCP protocols.

Architecture

packages/
  shared/       Zod schemas, errors, logger
  database/     Supabase client factory + migrations
  sdk/          NexusClient (AgentService, TaskService, TrustService)
  protocol/     A2A adapter
  mcp-server/   MCP tool server (Streamable HTTP)
apps/
  web/          Next.js 15 dashboard + API routes
examples/
  echo-agent/   Standalone A2A agent for testing

Prerequisites

  • Node.js >= 20
  • pnpm 9+
  • Supabase project with SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY

Quick Start

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Start the web dashboard (port 3000)
pnpm --filter @nexus-protocol/web dev

# Start the MCP server (port 4200)
pnpm --filter @nexus-protocol/mcp-server dev

# Start the echo agent for testing (port 4100)
pnpm --filter @nexus-protocol/echo-agent dev

Environment Variables

Create apps/web/.env.local:

SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

The MCP server reads SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY from the environment. You can export them or create a .env file.

MCP Integration

The NEXUS MCP server exposes agent discovery, task delegation, and trust queries to any MCP-compatible client over Streamable HTTP.

Endpoint: http://localhost:4200/mcp Health check: http://localhost:4200/health

Tools

Tool Description
discover_agents Find agents by skill tags, status, or trust score
delegate_task Assign a task to an agent and get the result
check_task_status Check status of a previously delegated task
get_agent_trust Get an agent's trust score and recent events

Resources

URI Description
nexus://agents All online agents (JSON)
nexus://agents/{id} Full details for a specific agent (JSON)

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "nexus": {
      "url": "http://localhost:4200/mcp"
    }
  }
}

Cursor

Add to .cursor/mcp.json in your project root:

{
  "mcpServers": {
    "nexus": {
      "url": "http://localhost:4200/mcp"
    }
  }
}

Claude Code

claude mcp add nexus --transport http http://localhost:4200/mcp

Testing with curl

# Health check
curl http://localhost:4200/health

# List available tools
curl -X POST http://localhost:4200/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

# Discover online agents
curl -X POST http://localhost:4200/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"discover_agents","arguments":{"status":"online"}}}'

# Delegate a task
curl -X POST http://localhost:4200/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"delegate_task","arguments":{"agentId":"<agent-uuid>","title":"Test task","input":{"message":"Hello"}}}}'

API Routes

Route Method Description
/api/v1/health GET Health check
/api/v1/agents GET/POST List/register agents
/api/v1/agents/[id] GET/PUT/DELETE Agent CRUD
/api/v1/agents/[id]/heartbeat POST Agent heartbeat
/api/v1/discover GET Discover agents with filters
/api/v1/tasks GET/POST List/create tasks
/api/v1/tasks/[id] GET Task details
/api/v1/tasks/[id]/reply POST Agent replies to task
/api/v1/tasks/[id]/cancel POST Cancel a task
/api/v1/a2a POST A2A JSON-RPC gateway
/.well-known/agent.json GET A2A Agent Card

License

Apache-2.0