Skip to content

feat(mcp): add the Orbit MCP server over streamable HTTP - #9

Merged
pulkitxm merged 9 commits into
mainfrom
feat/mcp-server
Jul 22, 2026
Merged

pulkitxm merged 9 commits into
mainfrom
feat/mcp-server

Conversation

@pulkitxm

Copy link
Copy Markdown
Member

Adds apps/mcp, an API key authenticated MCP server that exposes 23 Orbit tools backed by the core service layer and the shared permission policy.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7d7b705b-10ef-4eba-bb5b-ae8d5ed3e108

📥 Commits

Reviewing files that changed from the base of the PR and between e2d8f66 and 54fff17.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (23)
  • apps/mcp/README.md
  • apps/mcp/package.json
  • apps/mcp/src/auth.test.ts
  • apps/mcp/src/comments.ts
  • apps/mcp/src/create-key.ts
  • apps/mcp/src/env.ts
  • apps/mcp/src/index.ts
  • apps/mcp/src/logger.ts
  • apps/mcp/src/resolve.ts
  • apps/mcp/src/server.ts
  • apps/mcp/src/test-helpers.ts
  • apps/mcp/src/tools.test.ts
  • apps/mcp/src/tools/admin.ts
  • apps/mcp/src/tools/identity.ts
  • apps/mcp/src/tools/index.ts
  • apps/mcp/src/tools/issues.ts
  • apps/mcp/src/tools/planning.ts
  • apps/mcp/src/tools/support.ts
  • apps/mcp/src/views.ts
  • apps/mcp/tsconfig.json
  • apps/mcp/vitest.config.ts
  • packages/core/src/auth/api-key.ts
  • packages/core/src/index.ts

📝 Walkthrough

Walkthrough

Adds a new Orbit MCP application with streamable HTTP transport, bearer API-key authentication, identity-scoped tools for issues, planning, administration, and discovery, realtime delta responses, lifecycle management, CLI key provisioning, and Postgres-backed integration tests.

Changes

Orbit MCP server and API-key integration

Layer / File(s) Summary
API-key authentication and runtime
packages/core/src/auth/*, apps/mcp/src/create-key.ts, apps/mcp/src/index.ts, apps/mcp/src/env.ts, apps/mcp/src/logger.ts
Adds API-key generation, hashing, verification, expiry/revocation checks, CLI provisioning, runtime configuration, structured logging, and graceful shutdown.
HTTP transport and tool contracts
apps/mcp/src/server.ts, apps/mcp/src/resolve.ts, apps/mcp/src/tools/support.ts, apps/mcp/src/views.ts
Adds /health and authenticated /mcp routing, MCP transport handling, identifier resolution, standardized tool results/errors, and issue/delta view mapping.
Identity, planning, and administration tools
apps/mcp/src/tools/identity.ts, apps/mcp/src/tools/planning.ts, apps/mcp/src/tools/admin.ts
Registers principal-scoped tools for identity discovery, teams, labels, members, invitations, projects, progress, and cycles.
Issue and comment workflows
apps/mcp/src/tools/issues.ts, apps/mcp/src/comments.ts
Adds issue CRUD, search, movement, relations, comments, branch-name generation, project/cycle updates, permission checks, and published sync deltas.
Integration tests and operational documentation
apps/mcp/src/*.test.ts, apps/mcp/src/test-helpers.ts, apps/mcp/vitest.config.ts, apps/mcp/README.md
Adds database-backed authentication and tool tests, test database safeguards, package configuration, and setup/API documentation.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MCPClient
  participant MCPServer
  participant APIKeyService
  participant OrbitTools
  participant OrbitDB
  participant Redis
  MCPClient->>MCPServer: POST /mcp with Bearer API key
  MCPServer->>APIKeyService: verifyApiKey
  APIKeyService-->>MCPServer: authenticated principal
  MCPServer->>OrbitTools: execute requested tool
  OrbitTools->>OrbitDB: read or write Orbit data
  OrbitDB-->>OrbitTools: rows and sync actions
  OrbitTools->>Redis: publish sync actions
  OrbitTools-->>MCPServer: result and deltas
  MCPServer-->>MCPClient: JSON-RPC response
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
apps/mcp/package.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

apps/mcp/tsconfig.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Comment @coderabbitai help to get the list of available commands.

@pulkitxm

Copy link
Copy Markdown
Member Author

Live session over HTTP

Server started with MCP_PORT=3200 against the seeded dev database, key minted with the CLI. The
bearer token is redacted below; everything else is the real request and response.

Minting a key

$ pnpm --filter @orbit/mcp create-key -- --email [email protected] --name "Local agent"
workspace: Noveum (noveum)
user:      Pulkit Sharma <[email protected]>
key name:  Local agent
key id:    fa777a61-043b-48d8-9e4d-906cd9c9ad94

Copy this key now, it is not stored and cannot be shown again:
orb_************************************

Health, unauthenticated rejection, initialize

$ curl -s -i http://localhost:3200/health
HTTP/1.1 200 OK
content-type: application/json
content-length: 31
Date: Wed, 22 Jul 2026 19:25:43 GMT
Connection: keep-alive
Keep-Alive: timeout=5

$ curl -s -i -X POST http://localhost:3200/mcp -d '{...tools/list...}'   # no bearer token
HTTP/1.1 401 Unauthorized
content-type: application/json
content-length: 104
Date: Wed, 22 Jul 2026 19:25:43 GMT
Connection: keep-alive
Keep-Alive: timeout=5

{"jsonrpc":"2.0","error":{"code":-32000,"message":"Send an Orbit API key as a bearer token."},"id":null}
$ curl -s -X POST http://localhost:3200/mcp -H 'Authorization: Bearer orb_***' -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
    -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"1.0"}}}'
{
    "result": {
        "protocolVersion": "2025-06-18",
        "capabilities": {
            "tools": {
                "listChanged": true
            }
        },
        "serverInfo": {
            "name": "orbit",
            "version": "0.0.0"
        },
        "instructions": "Orbit is a work tracker. Issues live on teams and carry identifiers such as ENG-42. Call get_me first to learn the caller role and teams, then list_teams, list_states and list_labels before writing. Every tool acts as the user who owns the API key, so a request can fail with a forbidden error when their role does not allow it."
    },
    "jsonrpc": "2.0",
    "id": 1
}

Tools, identity, create, read, move, comment, search, branch name

### tools/list (names only)
$ curl -s -X POST http://localhost:3200/mcp -H 'Authorization: Bearer orb_***' -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' | jq -r '.result.tools[].name'
get_me
list_teams
list_users
list_states
list_labels
create_issue
update_issue
get_issue
search_issues
list_my_issues
move_issue
add_comment
set_relation
copy_branch_name
list_projects
create_project
project_progress
list_cycles
active_cycle
cycle_progress
move_to_cycle
list_members
invite_member

### get_me
$ curl -s -X POST http://localhost:3200/mcp -H 'Authorization: Bearer orb_***' \
    -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_me","arguments":{}}}'
{
  "result": {
    "structuredContent": {
      "user": {
        "id": "2774c4de-26d3-40bd-8526-0c85e140befd",
        "name": "Pulkit Sharma",
        "email": "[email protected]",
        "handle": "pulkit"
      },
      "organization": {
        "id": "org_noveum_demo",
        "name": "Noveum",
        "slug": "noveum"
      },
      "role": "admin",
      "permissions": [ "issue:read", "issue:create", "... 27 permissions ...", "audit:read" ],
      "teams": [
        {
          "id": "419057cd-cdc6-4706-8f49-dd9e5afc468e",
          "key": "DES",
          "name": "Design"
        },
        {
          "id": "ed99f640-24e8-4e54-96c7-b2d2c5715a56",
          "key": "ENG",
          "name": "Engineering"
        },
        {
          "id": "4f5906a5-873d-4a43-9f99-08d2758e75ce",
          "key": "MKT",
          "name": "Marketing"
        }
      ]
    }
  },
  "jsonrpc": "2.0",
  "id": 3
}

### create_issue
$ curl -s -X POST http://localhost:3200/mcp -H 'Authorization: Bearer orb_***' \
    -d '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"create_issue","arguments":{"team":"ENG","title":"Wire the MCP server into the agent workflow","description":"Expose Orbit tools over streamable HTTP.","priority":"high","assignee":"me","labels":["Feature"]}}}'
{
  "result": {
    "structuredContent": {
      "issue": {
        "id": "d46111df-3997-4900-a03f-f8e1f145b90d",
        "identifier": "ENG-20",
        "title": "Wire the MCP server into the agent workflow",
        "teamId": "ed99f640-24e8-4e54-96c7-b2d2c5715a56",
        "state": "Todo",
        "stateId": "561d9d76-51a0-4f04-88b7-633a451596e6",
        "priority": "High",
        "assignee": "Pulkit Sharma",
        "assigneeId": "2774c4de-26d3-40bd-8526-0c85e140befd",
        "projectId": null,
        "cycleId": null,
        "milestoneId": null,
        "parentId": null,
        "estimate": null,
        "dueDate": null,
        "archived": false,
        "updatedAt": "2026-07-22T19:25:43.534Z"
      },
      "deltas": [
        {
          "model": "issue",
          "action": "insert",
          "id": "d46111df-3997-4900-a03f-f8e1f145b90d"
        }
      ]
    }
  },
  "jsonrpc": "2.0",
  "id": 4
}

### get_issue by identifier
$ curl -s -X POST http://localhost:3200/mcp -H 'Authorization: Bearer orb_***' \
    -d '{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"get_issue","arguments":{"issue":"ENG-20"}}}'
{
  "result": {
    "structuredContent": {
      "issue": {
        "id": "d46111df-3997-4900-a03f-f8e1f145b90d",
        "identifier": "ENG-20",
        "title": "Wire the MCP server into the agent workflow",
        "teamId": "ed99f640-24e8-4e54-96c7-b2d2c5715a56",
        "state": "Todo",
        "stateId": "561d9d76-51a0-4f04-88b7-633a451596e6",
        "priority": "High",
        "assignee": "Pulkit Sharma",
        "assigneeId": "2774c4de-26d3-40bd-8526-0c85e140befd",
        "projectId": null,
        "cycleId": null,
        "milestoneId": null,
        "parentId": null,
        "estimate": null,
        "dueDate": null,
        "archived": false,
        "updatedAt": "2026-07-22T19:25:43.534Z",
        "description": "Expose Orbit tools over streamable HTTP.",
        "labels": [
          "Feature"
        ],
        "relations": []
      }
    }
  },
  "jsonrpc": "2.0",
  "id": 5
}

### move_issue
$ curl -s -X POST http://localhost:3200/mcp -H 'Authorization: Bearer orb_***' \
    -d '{"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"move_issue","arguments":{"issue":"ENG-20","state":"In Progress"}}}'
{
  "result": {
    "structuredContent": {
      "issue": {
        "id": "d46111df-3997-4900-a03f-f8e1f145b90d",
        "identifier": "ENG-20",
        "title": "Wire the MCP server into the agent workflow",
        "teamId": "ed99f640-24e8-4e54-96c7-b2d2c5715a56",
        "state": "In Progress",
        "stateId": "3c386ab9-080c-45e1-a467-5327226c4548",
        "priority": "High",
        "assignee": "Pulkit Sharma",
        "assigneeId": "2774c4de-26d3-40bd-8526-0c85e140befd",
        "projectId": null,
        "cycleId": null,
        "milestoneId": null,
        "parentId": null,
        "estimate": null,
        "dueDate": null,
        "archived": false,
        "updatedAt": "2026-07-22T19:25:43.716Z"
      },
      "rebalanced": 0,
      "deltas": [
        {
          "model": "issue",
          "action": "update",
          "id": "d46111df-3997-4900-a03f-f8e1f145b90d"
        }
      ]
    }
  },
  "jsonrpc": "2.0",
  "id": 6
}

### add_comment
$ curl -s -X POST http://localhost:3200/mcp -H 'Authorization: Bearer orb_***' \
    -d '{"jsonrpc":"2.0","id":7,"method":"tools/call","params":{"name":"add_comment","arguments":{"issue":"ENG-20","body":"Picked this up from the MCP server."}}}'
{
  "result": {
    "structuredContent": {
      "comment": {
        "id": "4503e96e-d5de-4910-a90f-8c9f09a125c7",
        "issue": "ENG-20",
        "body": "Picked this up from the MCP server.",
        "createdAt": "2026-07-22T19:25:43.761Z"
      },
      "deltas": [
        {
          "model": "comment",
          "action": "insert",
          "id": "4503e96e-d5de-4910-a90f-8c9f09a125c7"
        }
      ]
    }
  },
  "jsonrpc": "2.0",
  "id": 7
}

### search_issues
$ curl -s -X POST http://localhost:3200/mcp -H 'Authorization: Bearer orb_***' \
    -d '{"jsonrpc":"2.0","id":8,"method":"tools/call","params":{"name":"search_issues","arguments":{"query":"MCP","team":"ENG","limit":5}}}'
{
  "result": {
    "structuredContent": {
      "issues": [
        {
          "id": "d46111df-3997-4900-a03f-f8e1f145b90d",
          "identifier": "ENG-20",
          "title": "Wire the MCP server into the agent workflow",
          "teamId": "ed99f640-24e8-4e54-96c7-b2d2c5715a56",
          "state": "In Progress",
          "stateId": "3c386ab9-080c-45e1-a467-5327226c4548",
          "priority": "High",
          "assignee": "Pulkit Sharma",
          "assigneeId": "2774c4de-26d3-40bd-8526-0c85e140befd",
          "projectId": null,
          "cycleId": null,
          "milestoneId": null,
          "parentId": null,
          "estimate": null,
          "dueDate": null,
          "archived": false,
          "updatedAt": "2026-07-22T19:25:43.716Z"
        },
        {
          "id": "a9339f23-99f2-4248-a8c9-3e617df89864",
          "identifier": "ENG-19",
          "title": "Wire the MCP server into the agent workflow",
          "teamId": "ed99f640-24e8-4e54-96c7-b2d2c5715a56",
          "state": "In Progress",
          "stateId": "3c386ab9-080c-45e1-a467-5327226c4548",
          "priority": "High",
          "assignee": "Pulkit Sharma",
          "assigneeId": "2774c4de-26d3-40bd-8526-0c85e140befd",
          "projectId": null,
          "cycleId": null,
          "milestoneId": null,
          "parentId": null,
          "estimate": null,
          "dueDate": null,
          "archived": false,
          "updatedAt": "2026-07-22T19:23:32.378Z"
        },
        {
          "id": "625ee14f-9622-45ca-9f14-c7a75f8c3bb4",
          "identifier": "ENG-15",
          "title": "Expose the MCP server over streamable HTTP",
          "teamId": "ed99f640-24e8-4e54-96c7-b2d2c5715a56",
          "state": "Backlog",
          "stateId": "4f590467-1ad6-47cd-817d-42671edec728",
          "priority": "High",
          "assignee": null,
          "assigneeId": null,
          "projectId": null,
          "cycleId": null,
          "milestoneId": null,
          "parentId": null,
          "estimate": 8,
          "dueDate": null,
          "archived": false,
          "updatedAt": "2026-07-12T18:57:33.009Z"
        }
      ],
      "nextCursor": null
    }
  },
  "jsonrpc": "2.0",
  "id": 8
}

### copy_branch_name
$ curl -s -X POST http://localhost:3200/mcp -H 'Authorization: Bearer orb_***' \
    -d '{"jsonrpc":"2.0","id":9,"method":"tools/call","params":{"name":"copy_branch_name","arguments":{"issue":"ENG-20"}}}'
{
  "result": {
    "structuredContent": {
      "issue": "ENG-20",
      "branch": "pulkit/eng-20-wire-the-mcp-server-into-the-agent-workflow"
    }
  },
  "jsonrpc": "2.0",
  "id": 9
}

Graceful shutdown

$ kill -TERM <pid>
{"level":"info","message":"shutting down","at":"2026-07-22T19:23:54.517Z","service":"mcp","signal":"SIGTERM"}
$ curl -s -m 2 http://localhost:3200/health || echo "SERVER DOWN"
SERVER DOWN

Checks

$ pnpm verify
 Tasks:    8 successful, 8 total

@orbit/mcp contributes 28 tests across src/auth.test.ts and src/tools.test.ts, run against a
real Postgres (orbit_test_mcp).

pulkitxm added 7 commits July 23, 2026 00:57
Adds an api_key helper that generates orb_ prefixed keys, stores only a SHA-256 hash, verifies with a constant time compare, touches lastUsedAt, and rejects revoked or expired keys before resolving the owner principal.
Adds the @orbit/mcp app: a stateless streamable HTTP endpoint on MCP_PORT that authenticates every request with an Orbit API key, builds a server bound to the caller principal, answers GET /health, logs structured JSON, and shuts down cleanly on SIGTERM and SIGINT.
Twenty three tools that validate input with Zod, resolve human identifiers such as ENG-42 or a team key, call the matching core service with the caller principal, publish the returned SyncActions, and return a compact structured result. Domain errors come back as MCP tool errors instead of stack traces.
Drives the real HTTP server with an MCP client against Postgres: valid, revoked, expired and tampered keys, unauthenticated requests, a guest that can read but not write, an issue round trip by identifier, search filters, the sync actions a move emits, comments, relations and planning.
A small CLI mints a key for a seeded user and prints it once, and the README covers running the server, minting a key, connecting a client and the full tool list.
A domain error still reports its code and message, but anything that maps to a 500 comes back as a generic sentence so an unexpected failure cannot leak internals through the transport or a tool result.
@pulkitxm
pulkitxm merged commit e91bae0 into main Jul 22, 2026
3 of 4 checks passed
@pulkitxm
pulkitxm deleted the feat/mcp-server branch July 22, 2026 19:55
@pulkitxm

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant