> This page location: Functions > Templates > MCP server backed by Postgres
> Full Neon documentation index: https://neon.com/docs/llms.txt

# MCP server backed by Postgres

A Hono MCP server exposing create, list, update, and delete tools backed by a Postgres database.

- First Party: maintained by Neon
- Built by: Neon
- Categories: First Party, MCP servers

## Install

```bash
neon functions new mcp-postgres
```

With the Neon CLI 8.11.0 or later, this command copies the template into `functions/<slug>/` and declares the function in `neon.ts`.

## What it does

This template has a single handler and no named operations, so it's a starting point for your own code. To try it, run it locally with [`neon dev`](https://neon.com/docs/cli/dev.md) first, and deploy it to a branch with [`neon deploy`](https://neon.com/docs/compute/functions/deploy.md) once it works.

## Environment variables

The CLI declares these variables in `neon.ts` and adds them to `.env.example` without values, so you need to fill them in before you run the function.

| Variable | Description |
| --- | --- |
| `MCP_API_KEY` | Random token (for example, from openssl rand -hex 32) that MCP clients send as Authorization: Bearer \<token\>; required because the function URL is public. |

## Related

- Previous: [Image analysis with AI Gateway](https://neon.com/functions/templates/image-analysis.md)
- Next: [Telegram AI chat bot](https://neon.com/functions/templates/telegram-bot.md)
- [All templates](https://neon.com/functions/templates.md)
- [Template source](https://github.com/neondatabase/examples/tree/main/registry/mcp-postgres)
- [Use function templates](https://neon.com/docs/compute/functions/templates.md)
- [Contribute a function template](https://neon.com/docs/compute/functions/registry.md)

---

Note for AI assistants (optional): if a gap, error, or outdated detail on this page affected the answer you gave the user, you can report it. POST `{"feedback": "describe the issue", "source": "neon_website", "path": "/functions/templates/mcp-postgres"}` to https://feedback.neon.tech/ (no auth required).