mcp-server-smallinvoice

mcp-server-smallinvoice

MCP server for smallinvoice.ch — Swiss SME invoicing and accounting with 146 tools and OAuth2 BYOC authentication.

Category
访问服务器

README

@aiwerk/mcp-server-smallinvoice

MCP server for smallinvoice.ch — Swiss SME invoicing and accounting (146 tools, OAuth2 BYOC).

Install

npx -y @aiwerk/mcp-server-smallinvoice

Configure

Variable Required Description
SMALLINVOICE_CLIENT_ID OAuth2 client ID — smallinvoice Home → Users → API V2 → New client
SMALLINVOICE_CLIENT_SECRET OAuth2 client secret
SMALLINVOICE_REFRESH_TOKEN Initial refresh token from the OAuth bootstrap flow (rotates per call)
SMALLINVOICE_ACCESS_TOKEN optional Pre-loaded access token; lazily refreshed if absent or expired
SMALLINVOICE_TOKEN_FILE optional Path to persist rotating tokens (default: ~/.aiwerk/smallinvoice-tokens.json)
SMALLINVOICE_DRY_RUN optional Set to 1 to prevent write operations from reaching the API
SMALLINVOICE_NO_SNAPSHOT optional Set to 1 to disable pre-write entity snapshots
SMALLINVOICE_SNAPSHOT_DIR optional Directory for pre-write snapshots (default: ~/.aiwerk/smallinvoice-snapshots)
SMALLINVOICE_SNAPSHOT_FAIL_OPEN optional Set to 1 to log a warning instead of blocking when a snapshot fails
SMALLINVOICE_API_TIMEOUT_MS optional Request timeout in ms (default: 30000)

MCP client config example (Claude Desktop / OpenClaw)

{
  "mcpServers": {
    "smallinvoice": {
      "command": "npx",
      "args": ["-y", "@aiwerk/mcp-server-smallinvoice"],
      "env": {
        "SMALLINVOICE_CLIENT_ID": "your-client-id",
        "SMALLINVOICE_CLIENT_SECRET": "your-client-secret",
        "SMALLINVOICE_REFRESH_TOKEN": "your-initial-refresh-token"
      }
    }
  }
}

Auth setup

Requires smallinvoice Starter plan or higher (CHF 15/mo). The free tier blocks API access.

  1. In your smallinvoice account: Home → Users → API V2 → New client

    • Grant type: Authorization Code
    • Redirect URI: http://127.0.0.1:8765/callback (must be registered in the client config)
    • Copy client_id and client_secret
  2. Run the authorization URL in your browser:

    https://api.smallinvoice.com/v2/auth/authorize?response_type=code&client_id=YOUR_CLIENT_ID&scope=profile+contact+contact_reminder+letter+configuration+catalog+invoice+offer+delivery_note+order_confirmation+project+cost_unit+working_hours+activity+effort
    

    Log in and approve. You receive a code.

  3. Exchange the code for tokens:

    curl -X POST https://api.smallinvoice.com/v2/auth/access-tokens \
      -H 'Content-Type: application/json' \
      -d '{"grant_type":"authorization_code","client_id":"...","client_secret":"...","code":"...","redirect_uri":"http://127.0.0.1:8765/callback"}'
    

    The response contains access_token and refresh_token.

  4. Set SMALLINVOICE_REFRESH_TOKEN to the returned refresh_token. The server persists new tokens automatically after each refresh.

Token file is source of truth after first refresh. Once the server performs its first token rotation, the persisted SMALLINVOICE_TOKEN_FILE takes priority over SMALLINVOICE_REFRESH_TOKEN env var. If you rotate the refresh token manually, update or delete the token file.

Tools

146 tools total across 6 groups.

Group Count Representative tools
auth 2 get_owner, get_profile
contacts 42 list_contacts, get_contact, create_contact, update_contact, delete_contacts; sub-resources: accounts, addresses, people, groups, letters, reminders
catalog 22 list_products, create_product, list_services, create_service; categories (product & service), units
receivables 47 list_invoices, create_invoice, download_invoice_pdf, change_invoice_status, send_invoice_by_email, record_invoice_payment; offers, order-confirmations, delivery-notes, payments, ISRs
reporting 23 list_projects, list_working_hours; efforts, activities, cost-units
configuration 10 list_bank_accounts, create_bank_account; list_exchange_rates, create_exchange_rate

All delete_* tools are marked destructiveHint: true. All list_* / get_* / download_* tools are readOnlyHint: true.

Important notes

Refresh token rotation. Smallinvoice revokes the old refresh token the moment it issues a new one. The server uses atomic write (content fsync + atomic rename + dir fsync best-effort) to persist the new token before using it. If the process crashes after the API rotation but before persist completes, the OAuth chain is broken — re-run the bootstrap flow from step 2 above.

Cross-process refresh safety. Multiple MCP server instances sharing the same token file are protected by an O_EXCL file lock. A double-check after acquiring the lock avoids redundant refreshes when another process already rotated the token.

SMALLINVOICE_DRY_RUN=1. All write tools (create_*, update_*, delete_*, change_*, send_*, record_*) return a stub response without contacting smallinvoice:

{ "_dry_run": true, "_would_call": { "method": "POST", "path": "/receivables/invoices", "body": { ... } } }

Use this when testing against a production account.

Pre-write snapshots. Before each mutating operation, the current entity state is fetched and saved to ~/.aiwerk/smallinvoice-snapshots/. The tool result includes a _snapshot field with the file path.

  • PUT / PATCH — snapshots the entity being updated
  • DELETE — snapshots each entity being deleted (batch-aware: all IDs fetched in parallel, saved as one JSON file with partial-failure tolerance)
  • send_by_email / send_by_post — snapshots the parent document before sending ⚠️ IRREVERSIBLE: sends real email/post — pre-state snapshotted under ~/.aiwerk/smallinvoice-snapshots/
  • Sub-resource POST (e.g. record_invoice_payment, create_contact_account) — snapshots the parent entity before modifying it

Disable snapshots with SMALLINVOICE_NO_SNAPSHOT=1. By default, a snapshot failure blocks the write (fail-closed). Set SMALLINVOICE_SNAPSHOT_FAIL_OPEN=1 to downgrade to a warning and continue.

Rate limit. The actual limit is 360 requests/minute (not 1000 as stated in the public documentation). The server logs a warning to stderr when X-Rate-Limit-Remaining drops below 30.

Date formats. Use YYYY-MM-DD for date fields and YYYY-MM-DD HH:MM:SS for timestamp fields (no timezone — Europe/Zurich assumed).

License

MIT — AIWerk

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选