Skip to main content
Glama
sharpjsdev

ERP-File MCP Server

by sharpjsdev
README.md
# ERP & File MCP Server

A dual FastMCP (Model Context Protocol) server built with FastAPI. This application exposes two concurrent MCP servers natively routed via custom ASGI middleware to interact with backend ERP APIs and local/Google Sheets data.

## Features

- **Dual MCP Endpoints**:
  - `/mcp`: Connects to an external ERP API, caches data locally into PostgreSQL with adaptive fetching algorithms, and exposes tools for querying standard business reports.
  - `/mcp-file`: Loads data from a Google Sheet (if `GOOGLE_CREDENTIALS` provided) or a local file (Excel/CSV), exposing tools to list, search, and summarize data dynamically.
- **Adaptive Database Sync**: Heavily optimizes API usage by scaling fetch windows based on historical data density. Keeps a rolling cache up-to-date automatically using background concurrency.
- **Robust Error Handling**: Handles network, API, and credential failures seamlessly, preventing server crashes and falling back when sources become unreachable.

## Endpoints / Test Paths

- **ERP Data FastMCP**: `http://localhost:8080/mcp`
- **File / Sheets FastMCP**: `http://localhost:8080/mcp-file`

## Prerequisites

- Python 3.11+
- PostgreSQL
- Valid `.env` configuration (see `.env.example`)

## Environment Variables

Check `.env.example` for full configuration details. Key variables include:
- `DATABASE_URL`: PostgreSQL connection string.
- `GOOGLE_CREDENTIALS`: JSON string representation of a Google Service Account (optional, for Google Sheets integration).

## Running Locally

1. Install dependencies:
```bash
pip install -r requirements.txt
```

2. Start the Uvicorn server:
```bash
uvicorn main:app --host 0.0.0.0 --port 8080
```

## Docker

Build and run using Docker:
```bash
docker build -t erp-mcp-server .
docker run -p 8080:8080 --env-file .env erp-mcp-server
```