apiempresas-mcp 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +87 -3
- package/dist/index.js +242 -0
- package/package.json +48 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 APIEmpresas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# APIEmpresas MCP
|
|
2
|
+
|
|
3
|
+
Servidor [MCP](https://modelcontextprotocol.io) oficial de [APIEmpresas.es](https://apiempresas.es): datos de empresas españolas para Claude, Cursor, VS Code y cualquier asistente compatible con MCP.
|
|
4
|
+
|
|
5
|
+
Pregunta en lenguaje natural ("¿Mercadona está activa y quiénes son sus administradores?", "saca el CIF de estas 40 empresas", "¿esta empresa ha tenido un concurso?") y el asistente consulta la API con tu clave.
|
|
6
|
+
|
|
7
|
+
## Herramientas
|
|
8
|
+
|
|
9
|
+
| Herramienta | Qué hace | Plan |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| `get_company` | Empresa por CIF: razón social, estado, constitución, provincia, CNAE, forma jurídica (ISO 20275) y LEI; domicilio, socio único, matriz del grupo y administradores según plan | Free (datos recortados), Pro |
|
|
12
|
+
| `search_companies` | Buscar empresas por nombre | Free |
|
|
13
|
+
| `verify_company` | Verificación KYB: existe, activa, nombre y administrador (o socio único) coinciden y, si se pide, NIF-IVA en VIES; con forma jurídica, LEI, matriz y socio único (2 consultas) | Pro |
|
|
14
|
+
| `find_cif_by_name` | De nombre a CIF, hasta 100 a la vez, con provincia opcional para desempatar (solo cobra las coincidencias) | Pro |
|
|
15
|
+
| `get_borme_history` | Actos publicados en el BORME | Pro |
|
|
16
|
+
| `get_risk_profile` | Perfil de riesgo a partir del BORME | Business |
|
|
17
|
+
| `get_public_contracts` | Contratos públicos adjudicados | Business |
|
|
18
|
+
| `get_usage` | Plan, consultas disponibles y saldo de créditos (gratis; no funciona en el Sandbox) | Todos |
|
|
19
|
+
|
|
20
|
+
Todas son de solo lectura. Cada llamada gasta consultas de tu plan, igual que la API.
|
|
21
|
+
|
|
22
|
+
## Instalación
|
|
23
|
+
|
|
24
|
+
1. Crea una cuenta gratis (100 consultas, sin tarjeta) en [apiempresas.es](https://apiempresas.es/register?intent=api&plan=free&source=mcp) y copia tu API key del panel.
|
|
25
|
+
2. Añade el servidor a tu cliente (necesita Node.js 18 o superior).
|
|
26
|
+
|
|
27
|
+
### Claude Desktop
|
|
28
|
+
|
|
29
|
+
En `claude_desktop_config.json`:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"mcpServers": {
|
|
34
|
+
"apiempresas": {
|
|
35
|
+
"command": "npx",
|
|
36
|
+
"args": ["-y", "apiempresas-mcp"],
|
|
37
|
+
"env": { "APIEMPRESAS_API_KEY": "tu_api_key" }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Claude Code
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
claude mcp add apiempresas --env APIEMPRESAS_API_KEY=tu_api_key -- npx -y apiempresas-mcp
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Cursor
|
|
50
|
+
|
|
51
|
+
En `~/.cursor/mcp.json` (o `.cursor/mcp.json` en el proyecto), el mismo bloque `mcpServers` que en Claude Desktop.
|
|
52
|
+
|
|
53
|
+
### VS Code
|
|
54
|
+
|
|
55
|
+
En `.vscode/mcp.json`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"servers": {
|
|
60
|
+
"apiempresas": {
|
|
61
|
+
"type": "stdio",
|
|
62
|
+
"command": "npx",
|
|
63
|
+
"args": ["-y", "apiempresas-mcp"],
|
|
64
|
+
"env": { "APIEMPRESAS_API_KEY": "tu_api_key" }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Pruebas sin coste
|
|
71
|
+
|
|
72
|
+
Con `APIEMPRESAS_BASE_URL=https://apiempresas.es/api/sandbox/v1` las llamadas no gastan consultas (solo admite los CIF de prueba A15075062 y B00000000).
|
|
73
|
+
|
|
74
|
+
## Qué conviene saber
|
|
75
|
+
|
|
76
|
+
- El estado registral, el scoring y el perfil de riesgo los calcula APIEmpresas a partir del BORME: no son un certificado del Registro Mercantil.
|
|
77
|
+
- No cubre titular real, listas de sanciones o PEP, ni empresarios individuales (autónomos).
|
|
78
|
+
- Precios: Free 100 consultas; Pro 19 €/mes (3.000/mes); Business 49 €/mes (10.000/mes); bonos sin suscripción desde 9 €. IVA no incluido. Detalle en [apiempresas.es](https://apiempresas.es/#precios).
|
|
79
|
+
- Documentación completa de la API: [apiempresas.es/documentation](https://apiempresas.es/documentation).
|
|
80
|
+
|
|
81
|
+
## English
|
|
82
|
+
|
|
83
|
+
Official MCP server for [APIEmpresas.es](https://apiempresas.es), a REST API for Spanish company data: lookup by CIF (tax ID), name search, KYB verification, directors, BORME (Commercial Registry gazette) filings, public contracts and risk profile. Get a free API key (100 requests) at apiempresas.es and run `npx -y apiempresas-mcp` with `APIEMPRESAS_API_KEY` set.
|
|
84
|
+
|
|
85
|
+
## Licencia
|
|
86
|
+
|
|
87
|
+
MIT
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Servidor MCP de APIEmpresas.es
|
|
4
|
+
*
|
|
5
|
+
* Expone la API de datos de empresas españolas como herramientas de solo lectura para
|
|
6
|
+
* asistentes de IA (Claude, Cursor, VS Code...). Usa la API key del propio usuario:
|
|
7
|
+
* cada llamada gasta consultas de su plan, igual que si llamara a la API directamente.
|
|
8
|
+
*
|
|
9
|
+
* Variables de entorno:
|
|
10
|
+
* APIEMPRESAS_API_KEY (obligatoria) clave de https://apiempresas.es/dashboard
|
|
11
|
+
* APIEMPRESAS_BASE_URL (opcional) por defecto https://apiempresas.es/api/v1;
|
|
12
|
+
* https://apiempresas.es/api/sandbox/v1 para pruebas sin coste
|
|
13
|
+
*/
|
|
14
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
15
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
export const VERSION = '1.1.0';
|
|
18
|
+
const API_KEY = (process.env.APIEMPRESAS_API_KEY || '').trim();
|
|
19
|
+
const BASE_URL = (process.env.APIEMPRESAS_BASE_URL || 'https://apiempresas.es/api/v1').replace(/\/+$/, '');
|
|
20
|
+
const TIMEOUT_MS = 30_000;
|
|
21
|
+
/** Las respuestas grandes (historial del BORME, contratos) se recortan para no llenar el contexto. */
|
|
22
|
+
const MAX_CHARS = 60_000;
|
|
23
|
+
const SIGNUP_URL = 'https://apiempresas.es/register?intent=api&plan=free&source=mcp';
|
|
24
|
+
function texto(t, isError = false) {
|
|
25
|
+
return isError ? { content: [{ type: 'text', text: t }], isError: true } : { content: [{ type: 'text', text: t }] };
|
|
26
|
+
}
|
|
27
|
+
function json(data) {
|
|
28
|
+
let t = JSON.stringify(data, null, 2);
|
|
29
|
+
if (t.length > MAX_CHARS) {
|
|
30
|
+
t = t.slice(0, MAX_CHARS) + '\n… (respuesta recortada: pide menos resultados o una página concreta)';
|
|
31
|
+
}
|
|
32
|
+
return texto(t);
|
|
33
|
+
}
|
|
34
|
+
/** CIF/NIF en el formato que espera la API: sin espacios, guiones ni puntos y en mayúsculas. */
|
|
35
|
+
function limpiarCif(cif) {
|
|
36
|
+
return cif.replace(/[\s.\-]/g, '').toUpperCase();
|
|
37
|
+
}
|
|
38
|
+
const cifSchema = z
|
|
39
|
+
.string()
|
|
40
|
+
.min(9)
|
|
41
|
+
.max(15)
|
|
42
|
+
.describe('CIF/NIF de la empresa española, p. ej. A46103834 (se aceptan espacios y guiones)');
|
|
43
|
+
/** Mensaje de error útil para el asistente y para la persona: qué pasó y qué hacer. */
|
|
44
|
+
function mensajeError(status, body) {
|
|
45
|
+
const partes = [];
|
|
46
|
+
const b = body && typeof body === 'object' ? body : {};
|
|
47
|
+
const primero = b.messages && typeof b.messages === 'object' ? Object.values(b.messages)[0] : '';
|
|
48
|
+
const msg = b.message || b.detail || (typeof b.error === 'string' ? b.error : '') || (typeof primero === 'string' ? primero : '');
|
|
49
|
+
const code = typeof b.code === 'string' ? b.code : '';
|
|
50
|
+
partes.push(`Error ${status}${code ? ` (${code})` : ''}: ${msg || 'la API no ha devuelto detalle'}`);
|
|
51
|
+
// Qué hacer, según el código estable de la API (13-10-2026)
|
|
52
|
+
const plan = typeof b.required_plan === 'string' ? ` (necesita el plan ${b.required_plan === 'business' ? 'Business' : 'Pro'})` : '';
|
|
53
|
+
const consejos = {
|
|
54
|
+
API_KEY_MISSING: `Falta la API key. Se obtiene gratis en ${SIGNUP_URL} y se configura en APIEMPRESAS_API_KEY.`,
|
|
55
|
+
API_KEY_INVALID: `La API key no es válida. Se obtiene gratis en ${SIGNUP_URL} y se configura en APIEMPRESAS_API_KEY.`,
|
|
56
|
+
API_KEY_INACTIVE: 'La API key o la cuenta están desactivadas. Revísalo en el panel de APIEmpresas.',
|
|
57
|
+
COUNTRY_NOT_ALLOWED: 'La API key no admite peticiones desde este país (se configura en el panel).',
|
|
58
|
+
TEST_MODE_RESTRICTION: 'En el Sandbox solo valen los CIF de prueba A15075062 (encontrada) y B00000000 (no encontrada).',
|
|
59
|
+
PLAN_RESTRICTION: `Este dato no está incluido en el plan actual de la cuenta${plan}.`,
|
|
60
|
+
UPGRADE_REQUIRED: `Este dato no está incluido en el plan actual de la cuenta${plan}.`,
|
|
61
|
+
QUOTA_EXCEEDED: 'Se han agotado las consultas del plan y no queda saldo. Reintentar no sirve.',
|
|
62
|
+
TOO_MANY_REQUESTS: 'Demasiadas peticiones por segundo: espera un momento y vuelve a intentarlo.',
|
|
63
|
+
IP_LIMIT_EXCEEDED: 'Se ha alcanzado el límite de seguridad por IP del plan Free.',
|
|
64
|
+
PREVIEW_LIMIT_EXCEEDED: 'Se ha alcanzado el límite diario de vistas previas gratuitas. Vuelve mañana o mejora el plan.',
|
|
65
|
+
COMPANY_NOT_FOUND: 'No hay ninguna empresa con ese CIF o nombre en la base de datos.',
|
|
66
|
+
AUTONOMO_NOT_SUPPORTED: 'Es un DNI o NIE: la API solo tiene datos de sociedades, no de autónomos.',
|
|
67
|
+
FAKE_CIF_NOT_ALLOWED: 'Es un CIF de prueba: en producción usa un CIF real (los de prueba solo valen en el Sandbox).',
|
|
68
|
+
INVALID_CIF_FORMAT: 'El CIF no tiene un formato válido.',
|
|
69
|
+
RISK_PROFILE_NOT_AVAILABLE: 'La empresa existe, pero no tiene perfil de riesgo calculado.',
|
|
70
|
+
};
|
|
71
|
+
if (code && consejos[code]) {
|
|
72
|
+
partes.push(consejos[code]);
|
|
73
|
+
}
|
|
74
|
+
else if (status === 401) {
|
|
75
|
+
partes.push(consejos.API_KEY_INVALID);
|
|
76
|
+
}
|
|
77
|
+
else if (status === 403) {
|
|
78
|
+
partes.push('Este dato no está incluido en el plan actual de la cuenta.');
|
|
79
|
+
}
|
|
80
|
+
// Enlaces de compra que trae la propia API en los 403/429 (arriba o dentro de upsell_opportunities)
|
|
81
|
+
const etiquetas = {
|
|
82
|
+
starter_url: 'Bono de 1.000 créditos (pago único)',
|
|
83
|
+
checkout_url: 'Mejorar plan',
|
|
84
|
+
recharge_url: 'Recargar créditos',
|
|
85
|
+
upgrade_url: 'Planes',
|
|
86
|
+
};
|
|
87
|
+
const up = b.upsell_opportunities && typeof b.upsell_opportunities === 'object' ? b.upsell_opportunities : {};
|
|
88
|
+
const vistos = new Set();
|
|
89
|
+
for (const [k, etiqueta] of Object.entries(etiquetas)) {
|
|
90
|
+
const url = (typeof b[k] === 'string' && b[k]) || (typeof up[k] === 'string' && up[k]) || '';
|
|
91
|
+
if (url && !vistos.has(url)) {
|
|
92
|
+
vistos.add(url);
|
|
93
|
+
partes.push(`${etiqueta}: ${url}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return partes.join('\n');
|
|
97
|
+
}
|
|
98
|
+
async function llamar(path, init = {}) {
|
|
99
|
+
if (!API_KEY) {
|
|
100
|
+
return texto(`Falta la API key de APIEmpresas. Crea una cuenta gratis (100 consultas, sin tarjeta) en ${SIGNUP_URL}, ` +
|
|
101
|
+
'copia la clave del panel y ponla en la variable de entorno APIEMPRESAS_API_KEY de la configuración del servidor MCP.', true);
|
|
102
|
+
}
|
|
103
|
+
const controller = new AbortController();
|
|
104
|
+
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
105
|
+
try {
|
|
106
|
+
const headers = {
|
|
107
|
+
'X-API-KEY': API_KEY,
|
|
108
|
+
Accept: 'application/json',
|
|
109
|
+
'User-Agent': `apiempresas-mcp/${VERSION}`,
|
|
110
|
+
};
|
|
111
|
+
if (init.body)
|
|
112
|
+
headers['Content-Type'] = 'application/json';
|
|
113
|
+
const res = await fetch(`${BASE_URL}${path}`, { ...init, headers, signal: controller.signal });
|
|
114
|
+
const tipo = res.headers.get('content-type') || '';
|
|
115
|
+
const body = tipo.includes('application/json') ? await res.json().catch(() => null) : await res.text();
|
|
116
|
+
if (!res.ok) {
|
|
117
|
+
return texto(mensajeError(res.status, body), true);
|
|
118
|
+
}
|
|
119
|
+
return json(body);
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
if (e?.name === 'AbortError') {
|
|
123
|
+
return texto(`La API no respondió en ${TIMEOUT_MS / 1000} s. Prueba de nuevo en un momento.`, true);
|
|
124
|
+
}
|
|
125
|
+
return texto(`No se pudo conectar con la API (${BASE_URL}): ${e?.message || e}`, true);
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
clearTimeout(timer);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function qs(params) {
|
|
132
|
+
const p = new URLSearchParams();
|
|
133
|
+
for (const [k, v] of Object.entries(params)) {
|
|
134
|
+
if (v === undefined || v === '')
|
|
135
|
+
continue;
|
|
136
|
+
p.set(k, typeof v === 'boolean' ? (v ? 'true' : 'false') : String(v));
|
|
137
|
+
}
|
|
138
|
+
return p.toString();
|
|
139
|
+
}
|
|
140
|
+
const soloLectura = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true };
|
|
141
|
+
export function crearServidor() {
|
|
142
|
+
const server = new McpServer({ name: 'apiempresas', version: VERSION });
|
|
143
|
+
server.registerTool('get_company', {
|
|
144
|
+
title: 'Empresa por CIF',
|
|
145
|
+
description: 'Datos de una empresa española a partir de su CIF/NIF: razón social, estado (activa, extinguida, en concurso…), ' +
|
|
146
|
+
'fecha de constitución, provincia, municipio, CNAE, forma jurídica (con código ISO 20275) y código LEI y, según el ' +
|
|
147
|
+
'plan, domicilio completo, tramo de facturación, socio único (ownership), matriz del grupo según GLEIF (group) y ' +
|
|
148
|
+
'administradores (include_directors). Gasta 1 consulta. El estado lo calcula APIEmpresas a partir del BORME; ' +
|
|
149
|
+
'no es un certificado del Registro Mercantil. Spanish company lookup by tax ID.',
|
|
150
|
+
inputSchema: {
|
|
151
|
+
cif: cifSchema,
|
|
152
|
+
include_directors: z
|
|
153
|
+
.boolean()
|
|
154
|
+
.optional()
|
|
155
|
+
.describe('true para incluir administradores y cargos vigentes (planes Pro y Business)'),
|
|
156
|
+
},
|
|
157
|
+
annotations: soloLectura,
|
|
158
|
+
}, async ({ cif, include_directors }) => llamar(`/companies?${qs({ cif: limpiarCif(cif), admin: include_directors ? true : undefined })}`));
|
|
159
|
+
server.registerTool('search_companies', {
|
|
160
|
+
title: 'Buscar empresas por nombre',
|
|
161
|
+
description: 'Busca empresas españolas por nombre o razón social y devuelve las coincidencias con su CIF. ' +
|
|
162
|
+
'Útil cuando no se conoce el CIF. Search Spanish companies by name.',
|
|
163
|
+
inputSchema: {
|
|
164
|
+
query: z.string().min(2).describe('Nombre o parte del nombre de la empresa'),
|
|
165
|
+
limit: z.number().int().min(1).max(25).optional().describe('Número máximo de resultados (por defecto 10)'),
|
|
166
|
+
},
|
|
167
|
+
annotations: soloLectura,
|
|
168
|
+
}, async ({ query, limit }) => llamar(`/companies/search?${qs({ q: query, multiple: true, limit: limit ?? 10 })}`));
|
|
169
|
+
server.registerTool('verify_company', {
|
|
170
|
+
title: 'Verificación KYB',
|
|
171
|
+
description: 'Verificación KYB de una empresa en una sola llamada: si existe y está activa, si el nombre declarado coincide ' +
|
|
172
|
+
'y si una persona es administradora o el socio único, con alertas y una recomendación (pass / review / fail). ' +
|
|
173
|
+
'Devuelve también la forma jurídica, el LEI, la matriz del grupo y el socio único. ' +
|
|
174
|
+
'Plan Pro o superior; gasta 2 consultas. KYB check for a Spanish company.',
|
|
175
|
+
inputSchema: {
|
|
176
|
+
cif: cifSchema,
|
|
177
|
+
name: z.string().optional().describe('Razón social que ha declarado el cliente, para comprobar que coincide'),
|
|
178
|
+
person: z.string().optional().describe('Nombre de la persona que firma, para comprobar si es administradora o socia única'),
|
|
179
|
+
vat: z.boolean().optional().describe('true para comprobar además el NIF-IVA en VIES (operador intracomunitario)'),
|
|
180
|
+
},
|
|
181
|
+
annotations: soloLectura,
|
|
182
|
+
}, async ({ cif, name, person, vat }) => llamar(`/companies/verify?${qs({ cif: limpiarCif(cif), name, person, vat: vat ? true : undefined })}`));
|
|
183
|
+
server.registerTool('find_cif_by_name', {
|
|
184
|
+
title: 'De nombre a CIF',
|
|
185
|
+
description: 'Encuentra el CIF de una lista de empresas a partir de sus nombres (hasta 100). Cada resultado es match, ' +
|
|
186
|
+
'ambiguous o no_match; solo los match gastan consulta. Plan Pro o superior. Útil para completar hojas de clientes.',
|
|
187
|
+
inputSchema: {
|
|
188
|
+
names: z.array(z.string().min(2)).min(1).max(100).describe('Nombres de empresas'),
|
|
189
|
+
province: z
|
|
190
|
+
.string()
|
|
191
|
+
.optional()
|
|
192
|
+
.describe('Provincia (p. ej. VALENCIA) para desempatar entre empresas con el mismo nombre; se aplica a todos'),
|
|
193
|
+
},
|
|
194
|
+
annotations: soloLectura,
|
|
195
|
+
}, async ({ names, province }) => llamar('/companies/reconcile', {
|
|
196
|
+
method: 'POST',
|
|
197
|
+
body: JSON.stringify({ items: names.map((name) => (province ? { name, province } : { name })) }),
|
|
198
|
+
}));
|
|
199
|
+
server.registerTool('get_borme_history', {
|
|
200
|
+
title: 'Historial del BORME',
|
|
201
|
+
description: 'Actos publicados en el BORME (Boletín Oficial del Registro Mercantil) de una empresa: constitución, ' +
|
|
202
|
+
'nombramientos y ceses, ampliaciones de capital, cambios de domicilio, disolución, concurso… Plan Pro o superior.',
|
|
203
|
+
inputSchema: { cif: cifSchema },
|
|
204
|
+
annotations: soloLectura,
|
|
205
|
+
}, async ({ cif }) => llamar(`/companies/borme?${qs({ cif: limpiarCif(cif) })}`));
|
|
206
|
+
server.registerTool('get_risk_profile', {
|
|
207
|
+
title: 'Perfil de riesgo',
|
|
208
|
+
description: 'Perfil de riesgo de una empresa calculado a partir de sus publicaciones en el BORME (concursos, disoluciones, ' +
|
|
209
|
+
'cierres de hoja, cambios de administradores…), con nivel y explicación. Plan Business.',
|
|
210
|
+
inputSchema: { cif: cifSchema },
|
|
211
|
+
annotations: soloLectura,
|
|
212
|
+
}, async ({ cif }) => llamar(`/companies/risk-profile?${qs({ cif: limpiarCif(cif) })}`));
|
|
213
|
+
server.registerTool('get_public_contracts', {
|
|
214
|
+
title: 'Contratos públicos',
|
|
215
|
+
description: 'Contratos del sector público adjudicados a una empresa (Plataforma de Contratación del Sector Público). Plan Business.',
|
|
216
|
+
inputSchema: {
|
|
217
|
+
cif: cifSchema,
|
|
218
|
+
page: z.number().int().min(1).optional().describe('Página (por defecto 1)'),
|
|
219
|
+
limit: z.number().int().min(1).max(50).optional().describe('Contratos por página (por defecto 20)'),
|
|
220
|
+
},
|
|
221
|
+
annotations: soloLectura,
|
|
222
|
+
}, async ({ cif, page, limit }) => llamar(`/companies/contracts?${qs({ cif: limpiarCif(cif), page: page ?? 1, limit: limit ?? 20 })}`));
|
|
223
|
+
server.registerTool('get_usage', {
|
|
224
|
+
title: 'Consumo de la cuenta',
|
|
225
|
+
description: 'Plan de la cuenta, consultas usadas y disponibles, y saldo de créditos. No gasta consultas. No funciona en el Sandbox.',
|
|
226
|
+
inputSchema: {},
|
|
227
|
+
annotations: soloLectura,
|
|
228
|
+
}, async () => llamar('/usage'));
|
|
229
|
+
return server;
|
|
230
|
+
}
|
|
231
|
+
async function main() {
|
|
232
|
+
const server = crearServidor();
|
|
233
|
+
await server.connect(new StdioServerTransport());
|
|
234
|
+
// stdout es el canal del protocolo: los avisos van a stderr
|
|
235
|
+
if (!API_KEY) {
|
|
236
|
+
console.error(`[apiempresas-mcp] Falta APIEMPRESAS_API_KEY. Clave gratis en ${SIGNUP_URL}`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
main().catch((e) => {
|
|
240
|
+
console.error('[apiempresas-mcp] Error al arrancar:', e);
|
|
241
|
+
process.exit(1);
|
|
242
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "apiempresas-mcp",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "apiempresas-mcp",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Servidor MCP oficial de APIEmpresas.es: datos de empresas españolas (CIF, BORME, administradores, KYB, riesgo) para Claude, Cursor y otros asistentes de IA",
|
|
5
|
+
"mcpName": "io.github.abasmartinc/apiempresas",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"apiempresas-mcp": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"test": "npm run build && node tests/smoke.mjs",
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"mcp",
|
|
26
|
+
"model-context-protocol",
|
|
27
|
+
"apiempresas",
|
|
28
|
+
"empresas",
|
|
29
|
+
"cif",
|
|
30
|
+
"nif",
|
|
31
|
+
"borme",
|
|
32
|
+
"registro mercantil",
|
|
33
|
+
"kyb",
|
|
34
|
+
"spain",
|
|
35
|
+
"spanish companies"
|
|
36
|
+
],
|
|
37
|
+
"homepage": "https://apiempresas.es",
|
|
38
|
+
"author": "APIEmpresas",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
42
|
+
"zod": "^3.25.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^20.11.19",
|
|
46
|
+
"typescript": "^5.3.3"
|
|
47
|
+
}
|
|
48
|
+
}
|