Storno CLI--MCP服务器
A. 模型上下文协议(MCP)服务器 这暴露了整个 取消.ro 电子发票API作为AI收费工具。使Claude Code、Cursor、Windsurf和任何兼容MCP的AI助手能够管理发票、客户、公司、ANAF e-Factura等。
特性
- 237工具 涵盖所有Storno.ro API端点
- 完整的发票生命周期:创建、开具、提交给ANAF、发送电子邮件、下载PDF/XML
- 形式发票、经常性发票、送货单、贷记单
- 客户和产品目录、付款跟踪、增值税税率
- ANAF e-Factura集成(同步、令牌管理、消息检索)
- 公司切换的多公司支持
- 自动JWT令牌刷新
- Webhook、API密钥、团队成员管理
- 汇率(BNR)、报告、出口
快速开始
托管服务器(推荐)
Storno在以下位置托管公共MCP服务器 https://mcp.storno.ro/mcp 使用OAuth身份验证-无需管理API密钥或令牌。
访问 麦克普斯托诺罗 有关设置说明,请单击“添加到Claude”按钮。
克劳德(Claude.ai):
- 复制URL:
https://mcp.storno.ro/mcp - 首选 claude.ai/设置/连接器
- 点击“添加”并粘贴URL
- 通过OAuth授权
克劳德代码:```bash
claude mcp add storno --transport http https://mcp.storno.ro/mcp
**光标/风帆:**```json
{
"mcpServers": {
"storno": {
"url": "https://mcp.storno.ro/mcp"
}
}
}
克劳德桌面:```json
{
"mcpServers": {
"storno": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.storno.ro/mcp"]
}
}
}
### 自托管/基于令牌的设置
如果您更喜欢直接使用JWT令牌(例如用于自托管Storno实例):
#### 1.安装```bash
npm install -g storno-cli
或直接与 npx --无需安装。
2.配置Claude代码
添加到您的项目 .claude/settings.json 或全球 ~/.claude/settings.json:```json
{
"mcpServers": {
"storno": {
"command": "npx",
"args": ["-y", "storno-cli"],
"env": {
"STORNO_TOKEN": "your-jwt-token",
"STORNO_COMPANY_ID": "your-company-uuid"
}
}
}
}
#### 3.配置光标
添加 `.cursor/mcp.json`:```json
{
"mcpServers": {
"storno": {
"command": "npx",
"args": ["-y", "storno-cli"],
"env": {
"STORNO_TOKEN": "your-jwt-token",
"STORNO_COMPANY_ID": "your-company-uuid"
}
}
}
}
4.配置克劳德桌面
添加 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)或 %APPDATA%\Claude\claude_desktop_config.json (Windows):```json
{
"mcpServers": {
"storno": {
"command": "npx",
"args": ["-y", "storno-cli"],
"env": {
"STORNO_TOKEN": "your-jwt-token",
"STORNO_COMPANY_ID": "your-company-uuid"
}
}
}
}
## 环境变量
|变量|必填|默认|描述|
|----------|----------|---------|-------------|
| `STORNO_BASE_URL` |没有| `https://api.storno.ro` |API基本URL|
| `STORNO_TOKEN` |无\*|--|JWT访问令牌|
| `STORNO_REFRESH_TOKEN` |无|--|JWT刷新令牌(用于自动续订)|
| `STORNO_COMPANY_ID` |否\*|--|默认公司UUID|
| `STORNO_EMAIL` |否|--|自动登录电子邮件(如果没有令牌)|
| `STORNO_PASSWORD` |否|--|自动登录密码(如果没有令牌)|
| `STORNO_HTTP_PORT` |否|--|如果设置,则在此端口上启动可流式HTTP传输|
| `STORNO_HTTP_HOST` |没有| `127.0.0.1` |HTTP绑定地址(与 `STORNO_HTTP_PORT`) |
\*您可以在运行时使用 `auth_login` 工具代替。
## 认证
三种身份验证方式:
### 选项A:预配置令牌(建议用于生产)
集 `STORNO_TOKEN` 在MCP服务器环境配置中。
### 选项B:启动时自动登录
集 `STORNO_EMAIL` 和 `STORNO_PASSWORD`。服务器将在启动时自动登录并保持令牌刷新。
### 选项C:通过AI进行交互式登录
问AI: *“使用电子邮件登录Stornouser@example.com和密码mypassword“*
AI将调用 `auth_login` 该工具将令牌存储在会话的内存中。
## 多公司支持
所有公司范围的工具都需要公司背景。提供它的三种方法:
1. **环境变量**:设置 `STORNO_COMPANY_ID` 在MCP配置中
1. **选择命令**:让AI打电话 `companies_select` 具有公司UUID
1. **按请求覆盖**:每个公司范围的工具都接受一个可选工具 `companyId` 参数
AI对话示例:```
You: List my companies
AI: [calls companies_list] You have 2 companies:
- ABC SRL (uuid: 550e8400...)
- XYZ SRL (uuid: 661f9500...)
You: Switch to XYZ SRL
AI: [calls companies_select with uuid] Done, now using XYZ SRL
You: Show me recent invoices
AI: [calls invoices_list — automatically uses XYZ SRL context]
工具参考
看 TOOLS.md 所有237个工具的完整参考,包括描述和参数。
工具类别
| 类别 | 工具 | 描述 |
|---|---|---|
auth_* |
7 | 登录、注册、刷新令牌、个人资料管理 |
companies_* |
8 | 公司CRUD+上下文切换+ANF设置 |
invoices_* |
32 | 完整发票生命周期(创建→ 问题→ 提交→ 电子邮件→ PDF/XML) |
clients_* |
10 | 客户管理(从e-Factura同步) |
products_* |
2 | 产品目录 |
payments_* |
3 | 付款记录和跟踪 |
proforma_invoices_* |
12 | 形式生命周期(创建→ send → 接受/拒绝→ 转换) |
recurring_invoices_* |
10 | 经常性发票明细表 |
delivery_notes_* |
18 | 交货单生命周期+状态管理 |
receipts_* |
13 | 财政收入(bonuri fiscale)+转换为发票 |
vat_rates_* |
4 | 增值税税率CRUD |
bank_accounts_* |
4 | 银行账户CRUD |
document_series_* |
5 | 发票号码系列管理 |
suppliers_* |
8 | 供应商管理 |
exchange_rates_* |
2 | BNR汇率+货币兑换 |
email_templates_* |
4 | 电子邮件模板CRUD |
anaf_* |
8 | ANAF代币管理+e-Factura同步+验证 |
| efactura_messages_* 2.E-Factura消息检索。
einvoice_* · 6 · 多国电子发票(欧盟范围内)
dashboard_* · 1 · 仪表板统计信息
defaults_* · 1 · 发票默认值(货币、单位、增值税税率)
members_* · 3 · 组织团队成员
invitations_* · 4 · 团队邀请
notifications_* · 6 · 通知管理+首选项
webhooks_* · 10 · Webhook CRUD+测试+交付日志
api_keys_* · 5 · API代币管理
reports_* · 7 · 增值税报告+财务报告
exports_* · 1 · 导出文件下载
import_* · 8 · 客户、产品、发票的CSV/XLSX/XML导入
borderou_* · 8 · 银行对账(borderou)
backup_* · 6 · 备份创建+恢复
admin_* · 3 · 系统管理(需要管理员角色)
licensing_* · 4 · 许可证密钥管理
pdf_template_* · 4 · PDF发票模板定制
storage_config_* · 5 · 文件存储配置
accounting_export_* · 3 · 导出为会计格式
company_registry_* · 2 · 公司注册表查找
cpv_codes_* · 1 · CPV代码查找
nc_codes_* · 1 · NC代码查找
system_* · 2 · 系统运行状况+版本信息
常见AI工作流程
创建并发送发票```
You: Create an invoice for client Acme SRL, 10 hours web development at 100 RON/hour, due in 30 days
AI: [calls clients_list to find Acme SRL]
[calls invoices_create with clientId, lines, dates]
[calls invoices_issue to mark as issued]
[calls invoices_email to send to client]
Invoice FAC-2024-042 created, issued, and emailed to contact@acme.ro
### 检查ANAF同步状态```
You: What's the ANAF sync status for my company?
AI: [calls anaf_status]
Last sync: 2 hours ago, 156 invoices synced, token valid until March 16
生成月度报告```
You: Show me all invoices from January 2024
AI: [calls invoices_list with from=2024-01-01, to=2024-01-31]
Found 23 invoices, total: 45,230 RON
- 18 issued, 3 paid, 2 overdue
## HTTP传输
默认情况下,storno-cli使用 **stdio传输** 对于本地MCP客户。集 `STORNO_HTTP_PORT` 启用 **可流式HTTP传输** 用于远程访问。```bash
# Start HTTP server on port 3000
STORNO_TOKEN=your-token STORNO_COMPANY_ID=your-company-uuid \
STORNO_HTTP_PORT=3000 node dist/index.js
# Bind to all interfaces (for production behind a reverse proxy)
STORNO_HTTP_PORT=3000 STORNO_HTTP_HOST=0.0.0.0 node dist/index.js
服务器公开了一个 /mcp 根据MCP Streamable HTTP规范支持POST、GET和DELETE的端点。每个客户端连接都会创建一个隔离的有状态会话。
初始化会话:```bash
curl -X POST http://127.0.0.1:3000/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
Response includes mcp-session-id header
**调用工具:**```bash
curl -X POST http://127.0.0.1:3000/mcp \
-H "Content-Type: application/json" \
-H "mcp-session-id: " \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"system_health","arguments":{}}}'
发展```bash
npm run dev # Watch mode (recompile on changes)
npm run build # Production build
npm run start # Start MCP server (stdio)
## 建筑```
storno-cli/
├── src/
│ ├── index.ts # Entry point — dispatches to stdio or HTTP transport
│ ├── server.ts # McpServer factory (creates server + registers all tools)
│ ├── http-server.ts # Streamable HTTP transport with session management
│ ├── config.ts # Environment configuration
│ ├── client.ts # HTTP client with JWT auth + auto-refresh
│ ├── tools/ # 40 tool domain files (237 tools total)
│ │ ├── auth.ts
│ │ ├── invoices.ts # Largest: 32 tools for full invoice lifecycle
│ │ ├── companies.ts
│ │ └── ... # 37 more domain files
│ └── utils/
│ ├── errors.ts # AI-readable error formatting
│ └── pagination.ts # Pagination helpers
├── dist/ # Compiled JavaScript output
├── package.json
├── tsconfig.json
├── README.md # This file
└── TOOLS.md # Complete tool reference
需求
- Node.js>=20.0.0
- npm
许可证
弹性许可证2.0(ELv2)
