# LlmHelper MCP

An MCP server over LlmHelper's chat providers: see which services have keys, list models with prices and options, send a prompt to any model, and run raw Perplexity web searches, under a daily spending cap.

## Install

On a machine with LlmHelper installed, in PowerShell:

```
irm https://shakytext.com/llm/install.ps1 | iex
```

That installs the server to `%USERPROFILE%\LlmHelper\mcp\llm`, registers it with Claude Code as `llmhelper` (user scope) when the `claude` CLI is present, and prints the next steps. Re-run it to update. To register by hand:

```
claude mcp add --scope user llmhelper -- "%USERPROFILE%\LlmHelper\mcp\llm\LlmHelper.Mcp.exe"
```

Needs the .NET 8 Runtime (the installer offers it via winget).

## Keys

None to configure here. Save each provider's key once in **LlmHelper** (API Keys); this server reads them read-only from LlmHelper's database and never prompts.

## Tools

| Tool | Cost | What it does |
|---|---|---|
| `list_services` | free | Providers, whether LlmHelper has a key saved for each (never the key), model counts, today's spend |
| `list_models` | free | Model ids, USD per million tokens, per-request fees, web-search behaviour, and the options each model takes |
| `query` | paid | Prompt one model; returns the answer, citations, tokens and cost. Options a model doesn't take are rejected |
| `search` | paid ($0.005) | Perplexity Search API: ranked title/url/snippet/date, no AI answer |
| `get_job` | depends | Fetch a background-job answer by the `jobId` that `query` returned |
| `get_spend` | free | Today's spend, the daily cap, what is left |
| `set_spend_cap` | free | Change the daily cap (USD, 0 to 1000; 0 blocks paid calls) |

Queries are not saved to LlmHelper's history.

## Spending cap

The cap starts at **$2 a day** (local date). Before each paid call the server estimates its cost (the per-request fee plus the prompt's input tokens) and refuses the call, sending nothing, if today's spend plus that estimate would pass the cap. After the call it adds the actual cost (Perplexity's billed amount when the response carries it, otherwise the catalog price for the tokens used). Output tokens are only known after a call, so the last call of a day can take the total past the cap by its own output cost.

The cap and the log live in `%USERPROFILE%\LlmHelper\Llm` (`settings.json`, `spend.jsonl`) and are shared by every Claude session running the server. Ask Claude to change the cap, or edit `settings.json` (`{ "dailyCapUsd": 5 }`).

## Build from source

```
.\publish.ps1          # this machine
.\publish.ps1 -Site    # shakytext payload in bin\publish-anon
```
