{
  "markdown": "# Fortnox MCP Server\n\nAn MCP (Model Context Protocol) server for integrating with the Fortnox Swedish accounting system. This server enables LLMs to interact with Fortnox for managing invoices, customers, suppliers, orders, accounts, vouchers, and provides business intelligence analytics.\n\n## Two Ways to Use\n\n| Mode | Best For | Setup |\n|------|----------|-------|\n| **Remote Mode** | End users | Just add URL, authorize in browser |\n| **Local Mode** | Developers, self-hosted | Configure environment variables |\n\n---\n\n## Quick Start: Remote Mode (Recommended)\n\nThe easiest way to use Fortnox MCP - no credentials needed, just authorize in your browser.\n\n### Option A: Add to Claude.ai (Web)\n\n1. Go to [claude.ai](https://claude.ai)\n2. Navigate to **Settings** → **Integrations** → **Add Integration**\n3. Enter the URL: `https://fortnox-mcp.vercel.app/mcp`\n4. Wait for it to load, then authorize access by clicking connect\n\n### Option B: Add to Claude Desktop\n\nOpen your Claude Desktop config file:\n- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`\n- **Windows**: `%APPDATA%\\Claude\\claude_desktop_config.json`\n\nAdd this configuration:\n\n```json\n{\n  \"mcpServers\": {\n    \"fortnox\": {\n      \"url\": \"https://fortnox-mcp.vercel.app/mcp\"\n    }\n  }\n}\n```\n\nRestart Claude Desktop. When you first ask Claude to do something with Fortnox, a browser window will open for you to authorize access to your Fortnox account. Once authorized, you're all set!\n\n---\n\n## Quick Start: Local Mode (Self-Hosted)\n\nFor developers who want to run the server locally or use their own Fortnox app credentials.\n\n### 1. Get your Fortnox credentials\n\n1. Register at [Fortnox Developer Portal](https://developer.fortnox.se)\n2. Create an application to get your **Client ID** and **Client Secret**\n3. Complete the OAuth2 flow to get a **Refresh Token**\n\n### 2. Add to Claude Desktop\n\nOpen your Claude Desktop config file:\n- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`\n- **Windows**: `%APPDATA%\\Claude\\claude_desktop_config.json`\n\nAdd this configuration:\n\n```json\n{\n  \"mcpServers\": {\n    \"fortnox\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"fortnox-mcp-server\"],\n      \"env\": {\n        \"FORTNOX_CLIENT_ID\": \"your-client-id\",\n        \"FORTNOX_CLIENT_SECRET\": \"your-client-secret\",\n        \"FORTNOX_REFRESH_TOKEN\": \"your-refresh-token\"\n      }\n    }\n  }\n}\n```\n\n### 3. Restart Claude Desktop\n\nThat's it! You can now ask Claude to manage your Fortnox invoices, customers, and more.\n\n---\n\n## Features\n\n### Customer Management\n- `fortnox_list_customers` - List and search customers\n- `fortnox_get_customer` - Get customer details\n- `fortnox_create_customer` - Create new customer\n- `fortnox_update_customer` - Update customer\n- `fortnox_delete_customer` - Delete customer\n\n### Invoice Management\n- `fortnox_list_invoices` - List invoices with filtering\n- `fortnox_get_invoice` - Get invoice details with line items\n- `fortnox_create_invoice` - Create new invoice\n- `fortnox_update_invoice` - Update draft invoice\n- `fortnox_bookkeep_invoice` - Bookkeep invoice\n- `fortnox_cancel_invoice` - Cancel invoice\n- `fortnox_credit_invoice` - Create credit note\n- `fortnox_send_invoice_email` - Send invoice by email\n\n### Supplier Management\n- `fortnox_list_suppliers` - List and search suppliers\n- `fortnox_get_supplier` - Get supplier details\n- `fortnox_create_supplier` - Create new supplier\n- `fortnox_update_supplier` - Update supplier\n- `fortnox_delete_supplier` - Delete supplier\n\n### Supplier Invoice Management\n- `fortnox_list_supplier_invoices` - List supplier invoices with filtering\n- `fortnox_get_supplier_invoice` - Get supplier invoice details\n- `fortnox_approve_supplier_invoice` - Approve supplier invoice for payment\n- `fortnox_payables_report` - Get accounts payable aging report\n\n### Order Management\n- `fortnox_list_orders` - List sales orders with filtering\n- `fortnox_list_offers` - List offers/quotes with filtering\n\n### Account Management\n- `fortnox_list_accounts` - List chart of accounts\n- `fortnox_get_account` - Get account details\n- `fortnox_create_account` - Create new account\n- `fortnox_update_account` - Update account\n- `fortnox_delete_account` - Delete account\n\n### Voucher Management\n- `fortnox_list_vouchers` - List vouchers (journal entries)\n- `fortnox_get_voucher` - Get voucher details with rows\n- `fortnox_create_voucher` - Create manual voucher\n- `fortnox_list_voucher_series` - List available voucher series\n- `fortnox_account_activity` - Get activity for a specific account\n- `fortnox_search_vouchers` - Search vouchers by description, account, or amount\n\n### Company Information\n- `fortnox_get_company_info` - Get company details\n- `fortnox_list_financial_years` - List company financial years\n\n### Analytics\n- `fortnox_invoice_summary` - Get invoice statistics by period\n- `fortnox_top_customers` - Get top customers by revenue\n- `fortnox_unpaid_report` - Get detailed unpaid invoice report\n\n### Business Intelligence\n- `fortnox_cash_flow_forecast` - Forecast cash flow based on invoices and payables\n- `fortnox_order_pipeline` - Analyze sales order pipeline\n- `fortnox_sales_funnel` - Analyze sales funnel from offers to invoices\n- `fortnox_product_performance` - Analyze product/article performance\n- `fortnox_period_comparison` - Compare financial metrics across periods\n- `fortnox_customer_growth` - Analyze customer acquisition and growth\n- `fortnox_project_profitability` - Analyze project profitability (if using projects)\n- `fortnox_cost_center_analysis` - Analyze costs by cost center\n- `fortnox_expense_analysis` - Analyze expenses by category\n- `fortnox_yearly_comparison` - Compare year-over-year performance\n- `fortnox_gross_margin_trend` - Track gross margin trends over time\n\n## Installation\n\n### Via npx (Recommended)\n\nNo installation needed! Just add the config above to Claude Desktop.\n\n### Manual Installation\n\n```bash\nnpm install -g fortnox-mcp-server\n```\n\n### From Source\n\n```bash\ngit clone https://github.com/jakobwennberg/fortnox-mcp.git\ncd fortnox-mcp\nnpm install\nnpm run build\n```\n\n## Configuration\n\n### Environment Variables\n\n#### Local Mode (default)\n\n| Variable | Required | Description |\n|----------|----------|-------------|\n| `FORTNOX_CLIENT_ID` | Yes | Your Fortnox app client ID |\n| `FORTNOX_CLIENT_SECRET` | Yes | Your Fortnox app client secret |\n| `FORTNOX_REFRESH_TOKEN` | Yes | OAuth2 refresh token (only needed for initial setup; automatically persisted after first use) |\n| `FORTNOX_ACCESS_TOKEN` | No | Current access token (auto-refreshed) |\n| `TRANSPORT` | No | `stdio` (default) or `http` |\n| `PORT` | No | HTTP port (default: 3000) |\n\n#### Remote Mode (AUTH_MODE=remote)\n\n| Variable | Required | Description |\n|----------|----------|-------------|\n| `AUTH_MODE` | Yes | Set to `remote` |\n| `SERVER_URL` | Yes | Public URL of your server |\n| `JWT_SECRET` | Yes | Secret for signing JWT tokens |\n| `FORTNOX_CLIENT_ID` | Yes | Your Fortnox app client ID |\n| `FORTNOX_CLIENT_SECRET` | Yes | Your Fortnox app client secret |\n| `UPSTASH_REDIS_REST_URL` | Yes* | Upstash Redis URL for token storage |\n| `UPSTASH_REDIS_REST_TOKEN` | Yes* | Upstash Redis token |\n| `PORT` | No | HTTP port (default: 3000) |\n\n*Falls back to in-memory storage if not provided (not recommended for production)\n\n### Getting OAuth Credentials\n\n1. Register as a developer at [Fortnox Developer Portal](https://developer.fortnox.se)\n2. Create a new application to get Client ID and Client Secret\n3. Complete the OAuth2 authorization flow to obtain a refresh token\n4. Set the environment variables\n\n## Usage\n\n### With Claude Desktop\n\nSee [Quick Start](#quick-start-claude-desktop) above.\n\n### As HTTP Server\n\n```bash\nTRANSPORT=http PORT=3000 node dist/index.js\n```\n\nThen connect to `http://localhost:3000/mcp`\n\n## Tool Examples\n\n### List Unpaid Invoices\n```json\n{\n  \"tool\": \"fortnox_list_invoices\",\n  \"arguments\": {\n    \"filter\": \"unpaid\",\n    \"limit\": 20\n  }\n}\n```\n\n### Create Invoice\n```json\n{\n  \"tool\": \"fortnox_create_invoice\",\n  \"arguments\": {\n    \"customer_number\": \"1001\",\n    \"rows\": [\n      {\n        \"description\": \"Consulting services\",\n        \"quantity\": 10,\n        \"price\": 1000\n      }\n    ]\n  }\n}\n```\n\n### Create Voucher\n```json\n{\n  \"tool\": \"fortnox_create_voucher\",\n  \"arguments\": {\n    \"voucher_series\": \"A\",\n    \"description\": \"Office supplies\",\n    \"transaction_date\": \"2025-01-24\",\n    \"rows\": [\n      { \"account_number\": 6110, \"debit\": 500 },\n      { \"account_number\": 1910, \"credit\": 500 }\n    ]\n  }\n}\n```\n\n## Rate Limiting\n\nThe Fortnox API allows 25 requests per 5 seconds. This server includes automatic rate limiting to prevent exceeding this limit.\n\n## Development\n\n```bash\n# Run in development mode with auto-reload\nnpm run dev\n\n# Build for production\nnpm run build\n\n# Clean build artifacts\nnpm run clean\n```\n\n## Publishing & Distribution\n\nThis server is published to multiple registries for easy installation:\n\n| Registry | URL | Purpose |\n|----------|-----|---------|\n| **npm** | [npmjs.com/package/fortnox-mcp-server](https://www.npmjs.com/package/fortnox-mcp-server) | Package distribution via `npx` |\n| **MCP Registry** | [registry.modelcontextprotocol.io](https://registry.modelcontextprotocol.io) | Official MCP server discovery |\n| **GitHub** | [github.com/jakobwennberg/fortnox-mcp](https://github.com/jakobwennberg/fortnox-mcp) | Source code |\n\n### How It Works\n\n1. **User adds config** to Claude Desktop with `npx fortnox-mcp-server`\n2. **Claude Desktop starts the server** via npx (downloads latest version from npm)\n3. **Server authenticates** with Fortnox using OAuth2 credentials from environment variables\n4. **Claude can now use tools** like `fortnox_list_invoices`, `fortnox_create_customer`, etc.\n5. **Server handles API calls** to Fortnox, including automatic token refresh and rate limiting\n\n### Token Persistence (Local Mode)\n\nFortnox refresh tokens are single-use — each token refresh returns a new one. The server automatically persists the latest refresh token to `~/.fortnox-mcp/tokens.json` so it survives process restarts without requiring manual config updates.\n\n- On first run, the server reads `FORTNOX_REFRESH_TOKEN` from your environment/config\n- After each token refresh, the new refresh token is saved to `~/.fortnox-mcp/tokens.json`\n- On subsequent restarts, the server uses the persisted token (which is always the latest)\n- If the persisted file is missing or corrupt, the server falls back to the environment variable\n\nThe token file is created with restricted permissions (`0600`) for security.\n\n### Releasing New Versions\n\nTo release a new version, use the release script:\n\n```bash\n# Bug fixes (1.0.0 → 1.0.1)\nnpm run release:patch\n\n# New features (1.0.0 → 1.1.0)\nnpm run release:minor\n\n# Breaking changes (1.0.0 → 2.0.0)\nnpm run release:major\n```\n\nThe release script automatically:\n1. Bumps the version in `package.json`\n2. Updates `server.json` for the MCP Registry\n3. Builds the project\n4. Commits and tags the release\n5. Publishes to npm\n6. Publishes to MCP Registry\n7. Pushes to GitHub\n\n**Prerequisites for releasing:**\n- `npm login` - Logged into npm\n- `mcp-publisher login github` - Logged into MCP Registry\n- Clean git working directory\n\n### Users Get Updates Automatically\n\nWhen you publish a new version, users running `npx -y fortnox-mcp-server` will automatically get the latest version the next time they restart Claude Desktop.\n\n---\n\n## Deploying Your Own Remote Server\n\nWant to host your own instance of the Fortnox MCP server? Follow these instructions.\n\n### Deploy to Vercel\n\n[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/jakobwennberg/fortnox-mcp)\n\n#### 1. Prerequisites\n\n- A [Vercel](https://vercel.com) account\n- An [Upstash Redis](https://upstash.com) database (for token storage)\n- A [Fortnox Developer](https://developer.fortnox.se) account with an app created\n\n#### 2. Set Environment Variables\n\nIn your Vercel project settings, add these environment variables:\n\n| Variable | Description |\n|----------|-------------|\n| `AUTH_MODE` | Set to `remote` |\n| `SERVER_URL` | Your Vercel deployment URL (e.g., `https://your-app.vercel.app`) |\n| `JWT_SECRET` | A random secret string for signing tokens (generate with `openssl rand -hex 32`) |\n| `FORTNOX_CLIENT_ID` | Your Fortnox app client ID |\n| `FORTNOX_CLIENT_SECRET` | Your Fortnox app client secret |\n| `UPSTASH_REDIS_REST_URL` | Upstash Redis REST URL |\n| `UPSTASH_REDIS_REST_TOKEN` | Upstash Redis REST token |\n\n#### 3. Configure Fortnox OAuth Callback\n\nIn your Fortnox app settings, add this redirect URI:\n```\nhttps://your-app.vercel.app/oauth/fortnox/callback\n```\n\n#### 4. Deploy\n\n```bash\nvercel --prod\n```\n\n### Server Endpoints\n\n| Endpoint | Description |\n|----------|-------------|\n| `GET /health` | Health check |\n| `GET /.well-known/oauth-authorization-server` | OAuth metadata |\n| `POST /authorize` | Start OAuth flow |\n| `POST /token` | Exchange code for tokens |\n| `GET /oauth/fortnox/callback` | Fortnox OAuth callback |\n| `POST /mcp` | Protected MCP endpoint |\n\n### Architecture\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    fortnox-mcp-server                       │\n├─────────────────────────────────────────────────────────────┤\n│   Mode: AUTH_MODE=local | remote                            │\n├─────────────────────────────────────────────────────────────┤\n│                                                             │\n│   LOCAL MODE                    REMOTE MODE                 │\n│   ───────────                   ───────────                 │\n│   • Env var tokens              • OAuth flow                │\n│   • Single user                 • Multi-user                │\n│   • stdio or HTTP               • HTTP only                 │\n│   • Auto-persisted tokens       • Token storage (Redis)     │\n│     (~/.fortnox-mcp/)                                       │\n│                                                             │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## License\n\nMIT\n",
  "bytes": 14065,
  "sha": "7bdfc681fecae25c4dbf12f90e11489827b4ef1efd9ecc29430259fb11b791bd",
  "repo_slug": "jakobwennberg/fortnox-mcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_jakobwennberg_fortnox_8f5dc016/readme"
}