Skip to main content
Glama
Teltaq MCP HTTP server starter

Teltaq MCP HTTP server starter

by teltaq
README.md
# Teltaq MCP HTTP server starter

[![CI](https://github.com/teltaq/teltaq-mcp-http-server/actions/workflows/ci.yml/badge.svg)](https://github.com/teltaq/teltaq-mcp-http-server/actions/workflows/ci.yml)

A small [MCP](https://modelcontextprotocol.io) server over **Streamable HTTP** that you can
connect to [Teltaq](https://teltaq.com/docs/mcp) and call from any chat. It shows the part
of MCP that makes tools interactive, **elicitation**: a tool asks the user a question in
the middle of a call, Teltaq shows a card, the user answers, and the tool carries on.

| Tool | What it does |
|---|---|
| `echo(text)` | A plain tool with no elicitation |
| `book_table(restaurant)` | Asks for booking details in a **form** (date, party size 1–12, seating, optional notes), then for a yes / no confirmation. Answers differently for accept, decline and cancel |
| `link_account(service)` | **URL-mode** elicitation: Teltaq shows a link for the user to open, then **Done** or **Decline** |

Built on the official [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk).
Press **Use this template** to start your own server from it.

## What you need

- A Teltaq account on the **Pro** or **Team** plan (MCP servers).
- Python 3.10 or later and [uv](https://docs.astral.sh/uv/), or Docker.
- A public HTTPS address for the server. Teltaq runs in the cloud, so it can't reach
  `localhost` on your machine: deploy the container, or open a tunnel while you try it
  (for example `cloudflared tunnel --url http://localhost:8765` or `ngrok http 8765`).

## Run it

```bash
git clone https://github.com/teltaq/teltaq-mcp-http-server
cd teltaq-mcp-http-server
uv sync
export MCP_TOKEN=$(python -c "import secrets; print(secrets.token_urlsafe(32))")
uv run python server.py           # http://127.0.0.1:8765/mcp
```

With Docker:

```bash
docker build -t teltaq-mcp-http-server .
docker run -p 8765:8765 -e MCP_TOKEN=... -e MCP_ALLOWED_HOSTS=mcp.example.com teltaq-mcp-http-server
```

| Variable | Purpose |
|---|---|
| `MCP_TOKEN` | When set, every request needs `Authorization: Bearer <MCP_TOKEN>`; others get `401`. **Set it whenever the server is reachable from the internet** |
| `MCP_ALLOWED_HOSTS` | Comma-separated `Host` names to accept when listening on `0.0.0.0` (the SDK's DNS-rebinding guard). Without it the guard is off on public interfaces |
| `PORT` | Port to listen on (default `8765`; most hosting platforms set it) |

## Connect it to Teltaq

1. In Teltaq open **Settings → External MCP Servers → Add Server**.
2. **Endpoint**: your public address followed by `/mcp`, for example `https://mcp.example.com/mcp`.
3. **Headers**: `Authorization: Bearer <your MCP_TOKEN>`. Teltaq stores it encrypted; never put it
   in the URL.
4. **Test connection** lists the three tools. Save, then switch the server on for a chat
   (tools menu under the message box).

## Try it

- *"Echo hello"*: a normal tool result.
- *"Book a table at Luna"*: a form appears under the tool call. **Submit** shows the confirmation
  step; **Decline** and **Cancel** each return their own result. An invalid answer (party size 20)
  is refused inline and the form stays open.
- *"Link my GitHub account"*: a link card. Open it, then press **Done**.
- Press **Stop** while a form is waiting: the server sees the call cancelled, and the next message
  works as normal.

## Make it yours

- Add a tool with `@server.tool()` on an `async def`. Its docstring and type hints become the
  description and input schema the model sees.
- Ask the user for structured input with `Resolve(...)` + `Elicit(message, Model)`, where `Model` is
  a flat Pydantic model (MCP forms take strings, numbers, booleans and enums only).
- Send the user to a page (sign-in, payment, consent) with URL mode, as `link_account` does.
- Keep secrets in environment variables, never in tool results.
- Replace the static token with OAuth when several people connect with their own accounts;
  Teltaq supports OAuth 2.0 for MCP servers too.

## Tests

```bash
uv run pytest       # tools through the SDK's in-memory client, and the token check
uv run ruff check .
```

## Learn more

- [MCP servers in Teltaq](https://teltaq.com/docs/mcp), including how elicitation cards work
- A local (STDIO) starter for Teltaq for desktop: [teltaq-mcp-stdio-server](https://github.com/teltaq/teltaq-mcp-stdio-server)
- Calling Teltaq agents from other MCP clients: [teltaq-mcp-client](https://github.com/teltaq/teltaq-mcp-client)
- More samples: [github.com/teltaq](https://github.com/teltaq)

## Licence

MIT. See [LICENSE](LICENSE).