Skip to main content
Glama
mcp-rest-api-server

mcp-rest-api-server

mcp-rest-api-server

CI License: MIT

Portfolio demo, not client work. Built by Mustafa as a reference template for wrapping any REST API as a Model Context Protocol server. The Harborline API in this repo is fictional sandbox data.

Live page · GitHub · Offer

A TypeScript MCP server Claude Desktop, Claude Code, and Cursor can launch. Stdio and Streamable HTTP, Zod, cursor pagination, retries, and a read-only switch. Leave API_BASE_URL unset and the CLI boots the Harborline sandbox. No external account.

Demo: list projects, read a resource, and load a prompt

60-second quickstart

git clone https://github.com/mustafaautomation/mcp-rest-api-server.git
cd mcp-rest-api-server
npm install
npm run build
node dist/cli.js --help
npm run demo

Point Claude Desktop, Claude Code, or Cursor at the built CLI. Config snippets are in docs/configs/. For a checkout that is not published to npm yet:

{
  "mcpServers": {
    "harborline": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-rest-api-server/dist/cli.js"],
      "env": { "MCP_READ_ONLY": "true" }
    }
  }
}

The hosted read-only demo, once this repo is deployed at the apex domain, is https://mcp-api.quvantic.com/mcp. It serves the same sandbox. It does not accept writes.

The package is publish-ready (npx mcp-rest-api-server) and has not been published from this repo.

Related MCP server: mcp-api-bridge

Adapt to your API in 15 minutes

  1. Set API_BASE_URL and a read-only API_KEY. The sandbox steps aside.

  2. Replace the Zod objects in src/api/schemas.ts with your JSON.

  3. Map each endpoint to a method on src/api/client.ts. Tools do not call fetch.

  4. Register the tools in src/mcp/tools.ts. Leave write tools under the config.readOnly check.

  5. npm test, then paste a config from docs/configs/.

Page-number APIs stay behind cursorToPage / pageToCursor in src/api/pagination.ts. The model still sends cursor and limit. The longer walkthrough is docs/ADAPT.md.

Architecture

flowchart LR
  subgraph clients [MCP clients]
    Desktop[Claude Desktop]
    Code[Claude Code]
    Cursor[Cursor]
  end

  subgraph process [mcp-rest-api-server]
    Transport[stdio or Streamable HTTP]
    Layer[Tools, resources, prompts]
    Gate[Zod and read-only gate]
    HTTP[REST client]
  end

  API[(Harborline sandbox or your API)]

  Desktop --> Transport
  Code --> Transport
  Cursor --> Transport
  Transport --> Layer --> Gate --> HTTP --> API

stdout is the protocol. Logs go to stderr. The API key is read from the environment, attached as Authorization: Bearer or x-api-key, and scrubbed from log lines and tool errors.

The server uses @modelcontextprotocol/sdk 1.32.2, the latest release of that package. It speaks MCP 2025-11-25.

Tools

Read tools are always registered.

Tool

What it does

get_workspace_summary

Counts of projects, tasks, and contacts

list_projects

One page of projects

get_project

One project by id

list_tasks

Tasks, filterable by project, status, assignee

get_task

One task by id

list_contacts

Contacts, with an optional search string

get_contact

One contact by id

Write tools are registered only when the server is started with --read-write or MCP_READ_ONLY=false.

Tool

What it does

create_task

Create a task on an existing project

update_task

Patch one or more fields

create_contact

Create a contact. Email must be unique

The REST client also refuses POST and PATCH while read-only is on. A new write tool cannot bypass the flag by forgetting the check.

List tools take limit (1–100, default 20) and cursor. The result includes nextCursor and hasMore. Pass nextCursor back as cursor. Omit it to start over. Cursors are opaque. Don't invent them.

Resources

URI

Body

harborline://workspace/summary

Live counts, plus the server's read-only flag

harborline://contract

Auth, pagination, and the endpoint list. No live API key

harborline://projects/{projectId}

One project and its tasks

Prompts

Prompt

Arguments

What the model receives

project-status-brief

projectId

A brief grounded in the live project and tasks

client-update-email

projectId, optional tone

A short email. Tone is plain, warm, or formal

Configure

Copy .env.example. Real environment variables win over the file. Shell flags win over both.

Variable

Default

Role

API_BASE_URL

embedded sandbox

Upstream origin. Required for a real API

API_KEY

sandbox-demo-key for the sandbox

Required once API_BASE_URL is set

API_AUTH_STYLE

bearer

bearer, api-key, or both

API_KEY_HEADER

x-api-key

Header used for api-key and both

MCP_READ_ONLY

true

false registers write tools

API_TIMEOUT_MS

10000

Per-attempt timeout

API_MAX_RETRIES

3

Extra attempts after the first

API_RETRY_BASE_MS

200

Backoff base. Jitter is full

API_RETRY_MAX_MS

8000

Cap, including Retry-After

API_RATE_LIMIT_RPS

10

Token bucket refill

API_RATE_LIMIT_BURST

20

Burst shared by the process

MCP_HTTP_HOST

127.0.0.1

HTTP bind host

MCP_HTTP_PORT

8787

HTTP bind port

MCP_HTTP_TOKEN

unset

Bearer token required on /mcp when set

LOG_LEVEL

info

debug, info, warn, error, silent

--api-key exists and should be avoided. Flags are visible to other users on the machine. Put the key in the environment.

Retries: GET retries on 408, 429, 5xx, timeouts, and network errors. POST and PATCH retry on 408, 429, and connection failures that never left the machine (ECONNREFUSED, ENOTFOUND). A 500 on a write is returned once. Retry-After is honored up to API_RETRY_MAX_MS.

Errors from tools look like this:

{
  "error": {
    "code": "not_found",
    "message": "Project prj_missing was not found.",
    "status": 404,
    "requestId": "req_ab12cd34",
    "retryable": false
  }
}

Codes: unauthorized, not_found, validation, rate_limited, conflict, upstream, timeout, network, read_only.

Clients

Stdio is the path all three clients launch. The snippets in docs/configs/ use npx. Until the package is on npm, point command at Node and args at dist/cli.js.

Claude Desktop

~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows. See docs/configs/claude-desktop.json.

{
  "mcpServers": {
    "harborline": {
      "command": "npx",
      "args": ["-y", "mcp-rest-api-server"],
      "env": {
        "API_BASE_URL": "https://api.example.com",
        "API_KEY": "YOUR_API_KEY",
        "MCP_READ_ONLY": "true"
      }
    }
  }
}

Local checkout, sandbox included:

{
  "mcpServers": {
    "harborline": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-rest-api-server/dist/cli.js"],
      "env": { "MCP_READ_ONLY": "true" }
    }
  }
}

Claude Code

Project file .mcp.json, or user scope. See docs/configs/claude-code.mcp.json.

{
  "mcpServers": {
    "harborline": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "mcp-rest-api-server"],
      "env": {
        "API_BASE_URL": "https://api.example.com",
        "API_KEY": "YOUR_API_KEY",
        "MCP_READ_ONLY": "true"
      }
    }
  }
}
claude mcp add harborline \
  -e API_BASE_URL=https://api.example.com \
  -e API_KEY=YOUR_API_KEY \
  -e MCP_READ_ONLY=true \
  -- npx -y mcp-rest-api-server

Cursor

~/.cursor/mcp.json or .cursor/mcp.json in the project. See docs/configs/cursor.mcp.json.

{
  "mcpServers": {
    "harborline": {
      "command": "npx",
      "args": ["-y", "mcp-rest-api-server"],
      "env": {
        "API_BASE_URL": "https://api.example.com",
        "API_KEY": "YOUR_API_KEY",
        "MCP_READ_ONLY": "true"
      }
    }
  }
}

Streamable HTTP

node dist/cli.js http --port 8787

The process listens on 127.0.0.1 and checks the Host header. Bind 0.0.0.0 only when you set MCP_HTTP_TOKEN. The MCP endpoint is POST /mcp and answers JSON. GET /health is unauthenticated so a probe can use it.

MCP_HTTP_TOKEN=choose-a-long-token node dist/cli.js http --host 0.0.0.0 --port 8787

docs/configs/streamable-http.json shows the client side. Inspector:

npx @modelcontextprotocol/inspector --cli node dist/cli.js --method tools/list
npx @modelcontextprotocol/inspector --cli node dist/cli.js \
  --method tools/call --tool-name list_projects --tool-arg limit=2

npm run demo drives the same server with the official SDK client and prints a page of projects, a resource, and a prompt. A recording of that session is in docs/demo.gif. Regenerate it with vhs docs/demo.tape after npm run build.

Harborline sandbox

Fictional studio ops: six projects, sixteen tasks, eight contacts. The public demo key is sandbox-demo-key. It is not a credential for anything else.

node dist/cli.js mock --port 8788
curl -s localhost:8788/v1/projects?limit=2 -H "Authorization: Bearer sandbox-demo-key"

GET /health does not require a key. Everything under /v1 does, via bearer or x-api-key.

Docker

docker build -t mcp-rest-api-server .
docker run --rm -p 8787:8787 mcp-rest-api-server

The image serves Streamable HTTP on 0.0.0.0:8787 and boots the sandbox inside the container. Pass API_BASE_URL and API_KEY to use a real API, and MCP_HTTP_TOKEN before the port is reachable beyond your machine.

docker run --rm -p 8787:8787 \
  -e API_BASE_URL=https://api.example.com \
  -e API_KEY=YOUR_API_KEY \
  -e MCP_READ_ONLY=true \
  -e MCP_HTTP_TOKEN=choose-a-long-token \
  mcp-rest-api-server

Scripts

Script

What it does

npm run dev

Run the CLI from TypeScript

npm test

Vitest. Unit tests plus integration against the sandbox

npm run lint

ESLint

npm run typecheck

tsc on src, tests, and scripts

npm run build

Emit dist/

npm run demo

Client session recorded in docs/demo.gif

npm start

node dist/cli.js

CI (.github/workflows/ci.yml) runs lint, typecheck, test, and build on Node 22, then builds the Docker image and curls /health.

Publish

The bin entry is mcp-rest-api-server. npm pack runs the build. This checkout has not been published. When you publish from a machine that has npm credentials:

npm whoami
npm publish --access public

Confirm the name mcp-rest-api-server is still free first. No token is stored in this repo.

Landing page and hosted demo

Deploy the repository root on Vercel (Hobby is enough). The build copies site/ to public/ and publishes two functions:

Path

What it is

/

Landing page

/mcp

Read-only Streamable HTTP demo. JSON responses, sandbox data, no API key to configure

/health

Liveness JSON

  1. Import the repository in Vercel, or upload a prebuilt folder. Root Directory is the project root. Framework preset: Other.

  2. From git, the build command in vercel.json is npm run vercel-build. A direct upload can skip that compile: ship api/, public/, dist/, and a package.json whose only dependencies are the public packages @modelcontextprotocol/sdk, hono, and zod, and set the build command to empty. Vercel still runs npm install.

  3. Add the domain mcp-api.quvantic.com.

  4. Connect a client to https://mcp-api.quvantic.com/mcp.

The function is stateless and answers in one POST, with maxDuration of 10 seconds, which fits the Hobby plan. Do not point the hosted demo at a real API key. Writes stay off. A separate site/ root directory serves the page only and does not include /mcp.

FAQ

Is this a client project? No. Portfolio demo. Harborline is fictional.

Does the model see my API key? No. The key is an environment variable. Tool errors and logs scrub it.

Can it create records? Only when you start it with --read-write or MCP_READ_ONLY=false. The hosted demo does not.

What if my API uses page numbers? Keep the tool arguments as cursor and limit. Translate inside the REST client. See docs/ADAPT.md.

Which clients? Claude Desktop, Claude Code, and Cursor over stdio. Anything that speaks Streamable HTTP can use /mcp.

Where do I hire this? docs/OFFER.md. Three fixed-price packages.

Layout

src/cli.ts            stdio, http, and mock commands
src/server.ts         MCP server factory
src/api/client.ts     auth, pagination, rate limit, retries
src/mcp/              tools, resources, prompts
src/mock/             Harborline sandbox
docs/ADAPT.md         replace Harborline with your API
docs/OFFER.md         Fiverr gig and Upwork opening
docs/configs/         copy-paste client config
site/                 landing page

License

MIT. Copyright Mustafa.

Available Tools

7 tools
get_contactGet contactB
Read-onlyIdempotent

Fetch one contact by id.

Inputs: contactId (required). Returns: contact

get_projectGet projectB
Read-onlyIdempotent

Fetch one Harborline project by id, for example prj_northline.

Inputs: projectId (required). Returns: project

get_taskGet taskA
Read-onlyIdempotent

Fetch one task by id.

Inputs: taskId (required). Returns: task

get_workspace_summaryWorkspace summaryA
Read-onlyIdempotent

Counts of Harborline projects, tasks, and contacts, including tasks by status. Read-only.

Inputs: no named parameters. Returns: summary, readOnly

list_contactsList contactsA
Read-onlyIdempotent

List contacts. Optional q matches name, email, company, or role. Pages use cursor and limit.

Inputs: q, limit, cursor. Returns: limit, hasMore, contacts, nextCursor

list_projectsList projectsA
Read-onlyIdempotent

List Harborline projects one page at a time. Pass nextCursor back as cursor for the next page.

Inputs: limit, cursor. Returns: limit, hasMore, projects, nextCursor

list_tasksList tasksA
Read-onlyIdempotent

List tasks. Filter by projectId, status, or assigneeId. Pages use cursor and limit.

Inputs: limit, cursor, status, projectId, +1 more. Returns: limit, tasks, hasMore, nextCursor

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool maps to a distinct resource+action pair: three list_* tools for paging collections, three get_* tools for single-record fetches, and one summary/aggregate tool. The list/get split is explicit and reinforced by descriptions mentioning paging cursors versus id lookups. No two tools could plausibly be confused.

    Naming Consistency5/5

    Uniform snake_case verb_noun pattern throughout (get_*, list_*), with resources named consistently as projects, tasks, and contacts. The one aggregate tool, get_workspace_summary, still fits the get_* convention.

    Tool Count5/5

    Seven tools is well within the ideal range and every tool earns its place: one list and one get per each of the three entities, plus a summary. Nothing is redundant or padded.

    Completeness4/5

    Read coverage is complete and symmetric across all three resources (list + get for projects, tasks, contacts, plus an aggregate summary). The surface is read-only, and list_projects lacks the query/filter capability that list_tasks and list_contacts have, which is a minor asymmetry rather than a blocking gap.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Converts any REST API endpoints into MCP tools, enabling AI clients like Cursor and Claude Desktop to call internal services directly.
      -
    • A
      license
      B
      quality
      C
      maintenance
      Enables AI assistants like Claude to interact with any REST API through typed, validated MCP tools. Provides a pattern to wrap REST APIs as MCP servers.
      4
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables Claude to discover and call any REST API from an OpenAPI/Swagger spec or Postman collection at runtime, with authentication, workflows, and prebuilt registry support.
      MIT