home / mcp / alegra mcp server

Alegra MCP Server

Un servidor MCP (Model-Context Protocol) escrito en TypeScript para actuar como intermediario con la API de contabilidad de Alegra. El propósito es permitir que modelos de lenguaje grandes (LLMs) puedan interactuar y consultar información de facturas, contactos y artículos de forma segura.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "juancsanchez-alegra-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@juancsanchez/alegra-mcp"
      ],
      "env": {
        "ALEGRA_USER": "YOUR_ALEGRA_USER",
        "ALEGRA_TOKEN": "YOUR_ALEGRA_TOKEN"
      }
    }
  }
}

You can run a dedicated MCP server that acts as a secure bridge to Alegra’s accounting API, enabling your language models to interact with invoices, contacts, items, and more without exposing credentials outside your environment.

How to use

Configure your MCP client to point at the Alegra MCP, then start serving requests from your language model. You will provide credentials via environment variables, and all requests and errors will be logged locally for debugging.

How to install

Prerequisites you need before starting:

Node.js version 18 or higher

Alegra API credentials (user and token) ready for your environment

Choose one of the setup methods below and follow the steps exactly.

Direct NPX run (easy start for end users)

{
  "mcpservers": {
    "Alegra-MCP-Public": {
      "command": "npx",
      "args": [
        "-y",
        "@juancsanchez/alegra-mcp"
      ],
      "env": {
        "ALEGRA_USER": "[email protected]",
        "ALEGRA_TOKEN": "su_token_de_api_aqui"
      }
    }
  }
}

Local installation and run (developers)

If you want to modify or inspect the code, follow these steps exactly.

Prerequisites

Node.js 18 or newer

Alegra API credentials: a user and a token

1. Clone the repository

git clone https://github.com/juancsanchez/Alegra-MCP
cd alegra-mcp

2. Install dependencies

npm install

3. Create credentials file

touch .env

4. Add your Alegra credentials to .env

ALEGRA_USER="[email protected]"
ALEGRA_TOKEN="su_token_secreto_de_la_api"

5. Build the code

npm run build

6. Start the server

npm start

Available tools

AlegraAPI

Provides CRUD operations (GET, POST, PUT, DELETE) on Alegra API endpoints such as invoices, contacts, items, and more.

Logging

All requests and errors are written to a local log file alegra-mcp.log for debugging and traceability.