# Connect AI assistants to MyFoodNotes (MCP and HTTP API) MyFoodNotes runs its own MCP (Model Context Protocol) server at ``` https://myfoodnotes.com/mcp ``` It uses the "Streamable HTTP" transport. You do not need to install anything or run your own server. ## What the assistant can do | Tool | What it does | | --- | --- | | `save_recipe` | Saves a new recipe (title, description, ingredients, instructions, servings, times, tags, image and source URL) | | `search_recipes` | Searches your own recipes | | `get_recipe` | Fetches one recipe with ingredients and tags | | `list_recipes` | Lists your recipes, newest first | The assistant only sees your own recipes. It cannot edit or delete recipes, and it cannot see shopping lists, meal plans or family members. ## Sign-in - **OAuth (recommended):** the assistant opens MyFoodNotes, you sign in and approve. No key to copy. Supports OAuth 2.1 with PKCE and dynamic client registration. Discovery: `/.well-known/oauth-protected-resource` and `/.well-known/oauth-authorization-server`. - **API key:** for clients without OAuth, scripts and the xAI API. Create a key under **Profile → API keys and AI connections** and send it as `Authorization: Bearer mfn_…`. The key is shown only once. You can pick an expiry (never, 30, 90 or 365 days) and revoke it at any time. OAuth connections are listed under "Connected AI assistants" on your profile, where you can disconnect them. ## Setup per assistant Ready-made setup with copy buttons: https://myfoodnotes.com/en/help/ai-connections ### ChatGPT Settings → Apps & Connectors → Advanced → enable developer mode. Create a new connector with URL `https://myfoodnotes.com/mcp` and OAuth authentication. Sign in and approve. Requires Developer mode, which is only available on paid ChatGPT plans (Plus, Pro, Business, Enterprise, Edu), not the free plan. ### Claude (claude.ai and Claude Desktop) Settings → Connectors → Add custom connector. URL `https://myfoodnotes.com/mcp`. Sign in and approve. ### Claude Code ``` claude mcp add --transport http myfoodnotes https://myfoodnotes.com/mcp ``` Then run `/mcp` in Claude Code to sign in. ### Cursor `~/.cursor/mcp.json`: ```json { "mcpServers": { "myfoodnotes": { "url": "https://myfoodnotes.com/mcp" } } } ``` Cursor asks you to sign in. Alternatively add `"headers": { "Authorization": "Bearer mfn_YOUR_KEY" }`. ### VS Code (Copilot) `.vscode/mcp.json`: ```json { "servers": { "myfoodnotes": { "type": "http", "url": "https://myfoodnotes.com/mcp" } } } ``` ### Grok Grok CLI: `grok mcp add --transport http myfoodnotes https://myfoodnotes.com/mcp` (with the API key as a header if the client lacks OAuth). xAI API (Remote MCP Tools): ```json { "type": "mcp", "server_url": "https://myfoodnotes.com/mcp", "server_label": "myfoodnotes", "authorization": "Bearer mfn_YOUR_KEY" } ``` ### Other clients (stdio only) ```json { "mcpServers": { "myfoodnotes": { "command": "npx", "args": ["-y", "mcp-remote", "https://myfoodnotes.com/mcp", "--header", "Authorization: Bearer mfn_YOUR_KEY"] } } } ``` ## Pro AI connections are a Pro feature. When the Pro requirement is on, the tools reply with an upgrade message and the HTTP API returns `402` with `code: "TIER_LIMIT_API"`. ## HTTP API Base: `https://myfoodnotes.com/.netlify/functions/api-recipe`. Auth: `Authorization: Bearer mfn_…`. | Method | Request | Response | | --- | --- | --- | | `POST` | JSON recipe in the body | `201` with `recipe_id` (and `ignored_tags` if any tags were skipped) | | `GET` | `?id=` | One recipe | | `GET` | `?q=&limit=<1-50>` | Search | | `GET` | `?page=&limit=<1-100>` | List | Example: ```bash curl -X POST https://myfoodnotes.com/.netlify/functions/api-recipe \ -H "Authorization: Bearer mfn_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"title":"Pancakes","instructions":"Mix and fry.","ingredients":[{"name":"flour","amount":3,"unit":"dl"}],"servings":4,"tags":["breakfast"]}' ``` Fields: `title` (required), `instructions` (required), `description`, `ingredients` (`name`, `amount`, `unit`), `servings`, `prep_time`, `cook_time` (minutes), `tags`, `image_url`, `source_url`. ### Limits - Body max 100 KB. Title 200 characters, description 2,000, instructions 20,000. - Max 100 ingredients (name 200, unit 30 characters) and 20 tags (50 characters). - `image_url` and `source_url` must be `http(s)`, max 2,048 characters. - 60 requests per minute per key, then `429` with `Retry-After`. - Max 10 active API keys per account. ### Error codes | Code | Meaning | | --- | --- | | `400` | Invalid input (the message explains what) | | `401` | Missing, invalid, expired or revoked key | | `402` | Pro required (`TIER_LIMIT_API`) or recipe limit reached | | `404` | The recipe does not exist or is not yours | | `413` | Request too large | | `429` | Too many requests, retry after `Retry-After` seconds | ## Security - Keys are stored only as SHA-256 hashes. Never share a key or commit it to a public repo. - A key gives read and save access to your own recipes, nothing more. - Revoke keys and disconnect assistants you no longer use. ## Troubleshooting - **401:** check that the key is correct and not expired, or reconnect. - **Tools do not show up:** restart the client after changing its setup. - **Pro message:** upgrade at https://myfoodnotes.com/en/profile. - **Test:** use "Test connection" on your profile.