Pinin-MCP
<div align="center">
# Pinin MCP Server
**Photo restoration for AI agents — repair, colorize and upscale old photographs from Claude, Cursor, VS Code or any MCP client.**
[](https://github.com/UmbertoBiz/pinin-mcp/actions/workflows/ci.yml)
[](https://www.npmjs.com/package/pinin-mcp)
[](package.json)
[](LICENSE)
[](https://modelcontextprotocol.io)
[](https://glama.ai/mcp/servers/UmbertoBiz/pinin-mcp)
[Quick start](#quick-start) · [Tools](#tools) · [Clients](docs/clients.md) · [API docs](https://pinin.ai/developers/docs) · [Requirements](#requirements)
</div>
---
## What this is
[Pinin](https://pinin.ai) repairs damaged photographs: dust, scratches, tears, fading, mould staining. It also colorizes black-and-white photographs and upscales or deblurs soft scans.
This package connects a Model Context Protocol (MCP) client to Pinin's hosted MCP endpoint at **`https://pinin.ai/api/mcp`**. Ask your agent to restore a photo and it queues a job, follows it to completion and hands back a signed download link.
```text
You: Restore https://example.com/scan.jpg and give me the link when it's done.
Agent: pinin_restore_photo → job 887b66ff… · pending · 1 credit
pinin_get_restoration → processing · retry_after 5
pinin_get_restoration → completed in 12s
pinin_download_restoration → https://images.pinin.ai/…?exp=…&sig=…
```
**This repository is the pipe, not the engine.** Every tool call is an HTTPS request to Pinin's own endpoint, made with *your* key. Modes, credits, scopes, rate limits and retention are all enforced in one place, by the service.
---
## Quick start
Two things are needed: an **Enterprise** Pinin plan and an **API key**.
1. Create the key at <https://pinin.ai/developers> → *API keys*. A key can only be minted on an Enterprise plan, and every call additionally requires a positive credit balance.
2. Give the key to your client. It is the only configuration.
### Claude Desktop
Edit `claude_desktop_config.json` (`~/Library/Application Support/Claude/` on macOS, `%APPDATA%\Claude\` on Windows):
```json
{
"mcpServers": {
"pinin": {
"command": "npx",
"args": ["-y", "pinin-mcp"],
"env": { "PININ_API_KEY": "pnn_live_your_key_here" }
}
}
}
```
Restart Claude Desktop, then ask it to restore a photograph.
### Claude Code, Cursor, VS Code, Cline, Continue
Each client has its own config shape. Copy-paste versions live in **[docs/clients.md](docs/clients.md)**, and the JSON files themselves in [`examples/`](examples/).
```bash
# Claude Code
claude mcp add pinin --env PININ_API_KEY=pnn_live_your_key_here -- npx -y pinin-mcp
```
### Any client that speaks HTTP
The endpoint is a stateless Streamable HTTP MCP server. Point the client at it and send the key as a bearer token:
```bash
curl -s https://pinin.ai/api/mcp \
-H "Authorization: Bearer $PININ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
```
`X-API-Key: pnn_live_…` works too, for clients that own the `Authorization` header.
---
## Tools
Eight, fixed. A client cannot reach anything the API does not already publish.
| Tool | What it does | Cost |
|---|---|---|
| `pinin_restore_photo` | Queue one photograph, or a batch of up to 100. Takes a public `https` URL or inline base64. Supports `seed`, `idempotency_key` and `dry_run`. | 1 credit per image |
| `pinin_get_restoration` | Status, charge state, `expires_at`, signed image URLs. Returns `retry_after` while it runs. | free |
| `pinin_list_restorations` | Cursor-paginated history; `updated_since` reconciles everything that changed. | free |
| `pinin_download_restoration` | The signed URL for the restored file — or `image: "original"` for the source. Valid at least an hour. | free |
| `pinin_cancel_restoration` | Cancel a job that has not started. Nothing was charged, so nothing is refunded. | free |
| `pinin_get_account` | Plan, credit balance, batch cap, concurrency, the calling key's ceiling. | free |
| `pinin_get_usage` | Requests, errors, restorations and credits per day, and the month by key. | free |
| `pinin_list_modes` | The five restoration modes this account can request. | free |
Full reference — arguments, responses, failure modes: **[docs/tools.md](docs/tools.md)**.
### Modes
| Mode | Use it for |
|---|---|
| `all-in-one` | Everything at once — damage repair, colour, sharpening. The default. |
| `dust-scratch` | Speckles, tears, fold lines, emulsion damage. |
| `colorize` | Black-and-white to colour. An interpretation, not a record. |
| `deblur-upscale` | Soft focus, motion blur, low resolution. |
| `upscale-only` | Enlarge without changing anything else. |
---
## How it works
```text
MCP client ──stdio──▶ pinin-mcp (one file, no deps) ──HTTPS──▶ pinin.ai/api/mcp ──▶ api-v1 ──▶ models
```
The local process is a bridge: it reads JSON-RPC on stdin, forwards each message to the hosted endpoint with your key, and writes the answer to stdout. Nothing else — deliberately. A bridge that reimplemented the tools would be a second implementation to keep in sync, and a second place for a credit check to go missing.
The hosted endpoint decides nothing about pricing or entitlement. `api-v1` does, once, for the REST API, the webhooks and every integration (this server, n8n, Zapier, Make). Consequences worth knowing:
- `initialize` and `tools/list` are answered locally, from `tools.snapshot.json` — a copy of the hosted
catalogue committed beside the bridge. The server therefore starts and lists its eight tools with **no key
at all**, which is what lets a directory or a CI job containerise it, and it still picks up a tool added
upstream the moment a key is present. Only `tools/call` needs the key, and a missing one comes back as a
`-32001` message naming `PININ_API_KEY` rather than a process that exits with "Connection closed".
- A refusal comes back in the API's own words — `insufficient_credits`, `api_requires_enterprise`, `invalid_api_key` — not rewritten into "something went wrong".
- Your key is never logged, never echoed, never stored. It lives in the client's environment and in one request header.
---
## Requirements
| | |
|---|---|
| **Plan** | Enterprise. A key cannot be created on another plan, and a request cannot be served without an active subscription. |
| **Credits** | One per image, charged when the job settles, refunded when it fails. `dry_run` prices a request without spending. |
| **Node** | ≥ 18.17 for the local bridge (`fetch`, `AbortSignal.timeout`). Docker and raw HTTP clients skip this. |
| **Image source** | A public `https` URL, or inline base64 under a few MB. |
Pricing, credits and the exact ceilings: **[docs/pricing-and-limits.md](docs/pricing-and-limits.md)**.
---
## Security
- **The key is a credential.** Keep it on a server or in the client's environment — not in a browser bundle, a repository or a screenshot. Keys are shown once at creation.
- **Your photographs never touch this repository.** The bridge moves JSON on a pipe and makes HTTPS calls. It writes no files, caches nothing, keeps no queue.
- **Retention is 30 days** from submission. Every job states the moment as `expires_at`; an expired job answers `410 restoration_expired` rather than vanishing.
- **The endpoint is stateless.** No sessions, no SSE, no server-side registry of clients. `GET` and `DELETE` answer `405` with `Allow: POST, OPTIONS`.
- **Scopes are yours to set.** A key holds any combination of `restorations:read`, `restorations:write`, `usage:read`, `webhooks:manage`, `keys:manage`. Give an agent's key the narrowest set that works, plus a monthly credit cap.
Reporting a vulnerability: **[SECURITY.md](SECURITY.md)**.
---
## Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| `401` and *"That is not a Pinin API key"* | The value does not start with `pnn_live_`. | Copy the key again; the prefix is part of it. |
| `401 invalid_api_key` | Revoked, mistyped, or from another project. | Mint a new one. Revocation applies on the next request. |
| `401 missing_api_key` | No key reached the endpoint. | Set `PININ_API_KEY`, or send `Authorization: Bearer …` / `X-API-Key: …`. |
| `403 api_requires_enterprise` | Not on Enterprise, or the subscription is inactive. | Check the plan and its status. |
| `402 insufficient_credits` | Balance is zero. | Top up. `pinin_get_account` and `pinin_get_usage` stay readable while blocked, on purpose. |
| `429` | The key's requests-per-minute ceiling. | Back off; the response carries `retry-after`. |
| `410 restoration_expired` | The 30-day window closed. | Submit the image again. |
| A tool returns an error *result* with no protocol error | Tool failures are results, not JSON-RPC errors. | Read the result text — it carries the API's `code` and `request_id`. |
More: **[docs/errors.md](docs/errors.md)**.
## FAQ
**Is the MCP server free?**
The software is — MIT, no telemetry, no call-home. The service is not: restorations run on Enterprise plans and cost one credit per image.
**Does it work on a free or Pro plan?**
No. `403 api_requires_enterprise` is the answer at any other tier, in code rather than in policy text.
**Can I batch?**
Yes — up to 100 images per call, inside your plan's batch cap (500 on Enterprise) and 24 jobs in flight. Twenty photographs cost twenty credits.
**What happens if a restoration fails?**
The credit comes back automatically. A credit is charged only when a job settles successfully.
**Where do my photos go?**
Pinin fetches the image you point at, restores it, and stores the original and the result for 30 days. This repository stores nothing.
**Which clients are tested?**
Claude Desktop and Claude Code, Cursor and VS Code over stdio, and Streamable HTTP for everything else — [docs/clients.md](docs/clients.md) has the configs.
**Can I self-host?**
The server, yes: it is one file with no dependencies. The models are not in this repository, and the endpoint is Pinin's.
---
## Documentation
| | |
|---|---|
| [docs/tools.md](docs/tools.md) | Every tool: arguments, responses, errors |
| [docs/clients.md](docs/clients.md) | Per-client setup, Docker, remote HTTP |
| [docs/errors.md](docs/errors.md) | Error codes and what to do about them |
| [docs/pricing-and-limits.md](docs/pricing-and-limits.md) | Credits, plans, quotas, retention |
| [GLAMA.md](GLAMA.md) | Glama listing settings, remote and Docker |
| [pinin.ai/developers/docs](https://pinin.ai/developers/docs) | The REST API behind this server |
| [pinin.ai/openapi.json](https://pinin.ai/openapi.json) | OpenAPI 3.1 description |
| [pinin.ai/developers](https://pinin.ai/developers) | Console, keys, usage |
## Other integrations
The same API, with the same gate:
- **n8n** — community node `n8n-nodes-pinin`: restore, poll, cancel and download as workflow steps.
- **Zapier** — trigger on a finished restoration, plus actions for restore, get, cancel and usage.
- **Make** — importable scenario blueprints on the plain HTTP module.
- **REST** — <https://pinin.ai/developers/docs>.
## Contributing
Issues and pull requests are welcome — [CONTRIBUTING.md](CONTRIBUTING.md) has the test command and the two rules that matter (never log a key, never reimplement a tool). Security reports go through [SECURITY.md](SECURITY.md), never a public issue.
## License
[MIT](LICENSE) © Pinin SRL. The licence covers the code here, not the service or the name: Pinin is a proprietary hosted service, and using the API requires an account and is governed by <https://pinin.ai/terms-conditions>.
---
<div align="center">
<sub>MCP server · Model Context Protocol · photo restoration · image restoration API · colorize black and white photos · upscale old photos · Claude Desktop · Cursor · VS Code</sub>
</div>
TDQS
Scored across 8 tools
Each tool targets a distinct action on a distinct resource: create (restore_photo), read one (get_restoration), read many (list_restorations), cancel, download, plus modes/account/usage metadata. The descriptions actively pre-empt confusion, e.g. restore_photo explicitly excludes reading/listing/cancelling, and list_restorations says when to prefer it over get_restoration. The only mild overlap — download_restoration versus the URLs returned by get_restoration on a completed job — is called out and resolved in the text.
Every tool follows the same `pinin_` prefix plus a snake_case verb_noun pattern (get_restoration, list_restorations, cancel_restoration, download_restoration). Verbs are used consistently for their semantics: get for single reads, list for collections, cancel/download for the specific operation.
Eight tools is well within the sweet spot and each one earns its place — the create/read/list/cancel/download core plus three small metadata reads. Nothing appears redundant or padded; no operation is split into near-duplicate variants.
The full job lifecycle is covered: discover modes, size the account, submit, poll or sweep, cancel before processing, and fetch results, with usage analytics for spend questions. Minor gaps remain — no way to delete or purge jobs, no callback/webhook push alternative to polling, and no explicit re-submit/retry helper for failed jobs. These are workarounds an agent can manage, not dead ends.