facturas-mcp
facturas-mcp
DWH.facturas について Claude Desktop に質問するための読み取り専用 MCP サーバー。
仕組み
Claude Desktop がこのサーバーをローカルで起動する(専用プロセス、stdio で通信)。
サーバーは 読み取り専用 のログイン(
mcp_readonly)を使って SQL Server に接続する。 このログインにはDWH.facturasに対するGRANT SELECTしかない。その権限はデータベース 側にあり、このコードにはない -- これが実際のセキュリティの壁である。2 つのツールを公開する:
listar_columnas_facturas: Claude が SQL を書く前に列を発見できるようにする。consultar_facturas:DWH.facturasに対して読み取り専用のSELECTを実行する。
Related MCP server: mcp-mssql
手順 1 -- SQL Server で制限付きログインを作成する
データベースに対する管理者権限を持つユーザーで setup-db-login.sql を 一度だけ 実行する。
実行する前にサンプルのパスワードを変更すること。
手順 2 -- このサーバーの認証情報を設定する
このフォルダに .env ファイルを作成する(git にはアップロードされない):
MSSQL_SERVER=sintesiserp.com
MSSQL_DATABASE=Diverxamotos_4_2
MSSQL_USER=mcp_readonly
MSSQL_PASSWORD=la-contrasena-que-pusiste-en-el-paso-1手順 3 -- Claude Desktop にサーバーを登録する
claude_desktop_config.json を開き(Windows の場合: %APPDATA%\Claude\claude_desktop_config.json)、
"mcpServers" の中にこれを追加する:
{
"mcpServers": {
"facturas": {
"command": "node",
"args": ["C:\\Users\\Developer-07\\Documents\\DESARROLLO\\facturas-mcp\\dist\\index.js"],
"env": {
"MSSQL_SERVER": "sintesiserp.com",
"MSSQL_DATABASE": "Diverxamotos_4_2",
"MSSQL_USER": "mcp_readonly",
"MSSQL_PASSWORD": "la-contrasena-que-pusiste-en-el-paso-1"
}
}
}
}Claude Desktop を完全に終了してから開き直すと、新しいサーバーが読み込まれる。
手順 4 -- 動作確認する
Claude Desktop で、次のように質問する: 「DWH.facturas によると、今日の売上はいくら?」
後から別のテーブルを追加する
SQL Server で:
GRANT SELECT ON DWH.otratabla TO mcp_readonly;src/index.tsで: 配列ALLOWED_TABLESに"DWH.OTRATABLA"を追加し、必要に応じて 既存のものと同じlistar_columnas_otratablaツールも追加する。npm run buildを実行して Claude Desktop を再起動する。
リモートモード (Render) -- 複数の人が Claude.ai から使うために
デフォルトでは、サーバーは stdio モードで動作する(ローカル、ユーザーごとに 1 プロセス、
Claude Desktop が起動する)。複数の人が何もインストールせずに Claude.ai から使えるようにするには、
Render に HTTP サービスとしてデプロイできる。同じ dist/index.js が両方のモードに対応している --
切り替えは環境変数 MCP_TRANSPORT で行う。
重要: HTTP モードでは、データベースの唯一の保護は読み取り専用ログインのままであるが、
MCP サーバー自体 が公開 URL にさらされることになる。そのため HTTP モードではトークン
(MCP_AUTH_TOKEN)が必須である -- これがないとプロセスは起動すらしない。URL と トークンを
持っている人は誰でも DWH.facturas に対して SELECT を実行できる。したがって、そのトークンは
パスワードと同じように扱うこと: 公開しない、git にアップロードしない、漏えいしたらローテーションする。
手順 1 -- 強力なトークンを生成する
例えば、PowerShell で:
-join ((48..57)+(65..90)+(97..122)|Get-Random -Count 40|%{[char]$_})その値を保存する -- それが MCP_AUTH_TOKEN になる。
手順 2 -- Render で Web Service を作成する
このプロジェクトを GitHub リポジトリにアップロードする(
node_modulesとdistは リポジトリの外に置く必要がある -- これらはすでに.gitignoreに含まれている -- Render がnpm installとnpm run buildを自動で実行する)。Render で: New -> Web Service を選択し、リポジトリを接続する。
Build Command:
npm install && npm run buildStart Command:
npm startEnvironment variables(Environment タブ):
MCP_TRANSPORT=http MCP_AUTH_TOKEN=<el token del paso 1> MSSQL_SERVER=sintesiserp.com MSSQL_DATABASE=Diverxamotos_4_2 MSSQL_USER=mcp_readonly MSSQL_PASSWORD=<la contrasena del login de solo lectura>(Render が
PORTを自動的に定義する -- 追加する必要はない。)デプロイする。完了すると、Render から
https://facturas-mcp.onrender.comのような URL が提供される。
手順 3 -- サーバーが応答することを確認する
curl https://facturas-mcp.onrender.com/health
# {"status":"ok"}
curl -X POST https://facturas-mcp.onrender.com/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Authorization: Bearer <tu MCP_AUTH_TOKEN>" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'serverInfo と capabilities で応答すれば、サーバーは稼働していてトークンを受け付けている。
正しい Authorization ヘッダーがない場合は 401 を返すはずだ。
手順 4 -- Claude.ai / Claude Desktop から接続する
Claude.ai(または最近の Claude Desktop)で: Settings -> Connectors -> Add custom connector
を選択し、URL https://facturas-mcp.onrender.com/mcp を認証ヘッダー
Authorization: Bearer <tu MCP_AUTH_TOKEN> 付きで登録する(正確な UI は Claude のバージョンに
よって異なる場合がある -- リモート MCP サーバー / カスタムコネクタのオプションを探すこと)。
注: Render の free プランは、非アクティブになるとサービスを「スリープ」させる -- スリープ後の最初の リクエストは応答まで数秒かかることがある。
Available Tools
2 toolsconsultar_facturasA
Ejecuta una consulta SQL de solo lectura (SELECT) contra la tabla DWH.facturas para responder preguntas de negocio (ventas del dia, totales por cliente, facturas de un periodo, etc). Solo se permite SELECT sobre DWH.facturas -- cualquier otra cosa se rechaza. Si no conoces las columnas de la tabla, usa primero la herramienta listar_columnas_facturas.
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | Consulta SQL SELECT contra DWH.facturas. Ejemplo: SELECT SUM(valor) AS total FROM DWH.facturas WHERE fecha = '2026-08-19' |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No hay anotaciones, por lo que la descripción asume la responsabilidad de informar el comportamiento. Revela que solo es una operación de lectura, que acepta únicamente SELECT y que cualquier otra consulta será rechazada. Esto es un contexto conductual valioso, aunque no detalla formato de respuesta ni límites de ejecución.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tres oraciones con información esencial y sin relleno. La restricción crítica (solo SELECT) está al frente, y la referencia a la herramienta hermana es breve y pertinente.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Para una herramienta de un solo parámetro, la descripción cubre el propósito, las restricciones de uso y el paso a seguir si falta conocimiento de columnas. No hay anotaciones ni esquema de salida, pero el contexto entregado es suficiente para que el agente invoque la herramienta correctamente.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
El esquema cubre el 100% del parámetro sql y ya incluye descripción y ejemplo, así que la descripción no necesita añadir mucho. La descripción refuerza que el SQL debe ser SELECT y contra DWH.facturas, pero no agrega detalles semánticos nuevos más allá del esquema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
La descripción usa un verbo específico ('Ejecuta una consulta SQL de solo lectura') y un recurso concreto ('tabla DWH.facturas'), dejando claro qué hace la herramienta. Además, la diferencia de la herramienta hermana listar_columnas_facturas al indicar que ésta es para consultar datos, no para conocer columnas.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Indica explícitamente cuándo usarla: para responder preguntas de negocio que requieran datos de DWH.facturas. También establece exclusions ('solo se permite SELECT... cualquier otra cosa se rechaza') y recomienda usar listar_columnas_facturas cuando no se conocen las columnas, lo que orienta claramente al agente.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
listar_columnas_facturasA
Devuelve el nombre y tipo de cada columna de la tabla DWH.facturas. Usa esta herramienta primero, antes de escribir una consulta, si no conoces el esquema de la tabla.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the burden of disclosing behavior. It clearly indicates a read-only metadata operation returning column names and types, and its wording implies no side effects on the table. It doesn't detail output formatting, but that is a minor gap for a schema-listing tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two short sentences with no filler. The primary function is stated first, followed by a concise usage directive. Every sentence earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter schema-inspection tool with no output schema, the description is complete: it states the return content, the target table, and the appropriate invocation point relative to querying. An agent has enough information to use the tool correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so the baseline of 4 applies. The description adds useful context about which table is inspected and when the tool should be used, even though there are no parameters to explain.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb and resource: it returns the name and type of each column in DWH.facturas. This clearly separates the tool from the sibling consultar_facturas, which is presumably for querying data rather than inspecting schema.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly says to use this tool first, before writing a query, when the table schema is unknown. It gives clear situational guidance, though it doesn't explicitly name the alternative tool or state when not to use it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
2 tool updates
v1.0.0- First observed
consultar_facturas - First observed
listar_columnas_facturas
TDQS
Scored across 2 tools
The two tools have clearly distinct roles: one is for inspecting the table schema, the other for executing read-only SQL queries against the table. There is no overlap or ambiguity about which to call.
Both tool names follow the same lowercase snake_case verb_object pattern in Spanish: listar_columnas_facturas and consultar_facturas. The naming is predictable and aligns with each tool's function.
With only two tools, the server is minimal, but the scope is intentionally narrow: schema discovery plus SQL querying of a single invoices table. This is slightly below the typical 3-15 tool range but reasonable and well-scoped for its purpose.
For a read-only query server over DWH.facturas, the surface is complete: agents can discover the schema and then run arbitrary SELECT queries to answer business questions. No obvious additional operations are needed for the stated purpose.
Maintenance
Related MCP Connectors
Spanish Veri*factu invoicing: create invoices, expenses and VAT returns from your AI assistant.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
- KonnektaOAuthnl.konnekta
Connect Claude to Dutch accounting software: e-Boekhouden invoices, contacts and ledgers.
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to connect and query Microsoft SQL Server databases using natural language, executing read-only SQL queries for safe data inspection and analysis.MIT
- AlicenseAqualityDmaintenanceEnables natural language to SQL queries on MSSQL databases via Claude, with safe SELECT-only execution and schema discovery.3ISC
- AlicenseNot gradedqualityDmaintenanceProvides secure SQL Server database access, allowing users to list tables and execute SQL queries through natural language in Claude Desktop.MIT
- FlicenseNot gradedqualityDmaintenanceEnables secure interaction with Microsoft SQL Server databases, allowing schema exploration, metadata retrieval, and read-only query execution through natural language.1-