nlp-fastapi-mcp-server

di37/nlp-fastapi-mcp-server

3.2

If you are the rightful owner of nlp-fastapi-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Electrical NER API and MCP Service provides specialized Named Entity Recognition for the Electrical Engineering domain, accessible via RESTful API and MCP service.

Tools
2
Resources
0
Prompts
0

Electrical NER API and MCP Service

This project provides service for Named Entity Recognition (NER) specifically tailored for the Electrical Engineering domains. It can be accessed both as a standard RESTful API and as a Model Context Protocol (MCP) service, making it easy to integrate into various workflows.

Features

  • Dual Interface: Accessible via a standard RESTful API and as a Model Context Protocol (MCP) service.
  • High Performance: Built with FastAPI and Uvicorn for fast, asynchronous request handling.
  • Specialized NER Model: Utilizes a fine-tuned NER model specifically tailored for the Electrical Engineering domain.
  • Seamless MCP Integration: Exposes core NER functions as an MCP service for easy use with agentic AI systems.

API Documentation

The API provides the following endpoints:

GET /

Root endpoint to verify that the service is running.

  • Success Response (200):
    {
      "status": "running",
      "timestamp": "2023-10-27T10:00:00.000Z",
      "service": "Electrical NER API",
      "version": "1.0.0"
    }
    

GET /health

Basic health check endpoint.

  • Success Response (200):
    {
      "status": "healthy",
      "timestamp": "2023-10-27T10:00:00.000Z",
      "service": "Electrical NER API",
      "version": "1.0.0"
    }
    

GET /all_entities

Retrieves a list of all possible entity groups that the model can recognize.

  • Success Response (200):
    [
      "COMPONENT",
      "DESIGN_PARAM",
      "MATERIAL",
      "EQUIPMENT",
      "TECHNOLOGY",
      "SOFTWARE",
      "STANDARD",
      "VENDOR",
      "PRODUCT"
    ]
    

POST /predict

Extracts entities from the provided input text.

  • Request Body:

    {
      "text": "The LM358 operational amplifier from Texas Instruments needs a dual power supply."
    }
    
  • Success Response (200):

    {
      "success": true,
      "message": "Entities detected successfully",
      "entities": [
        {
          "entity_group": "PRODUCT",
          "word": "LM358"
        },
        {
          "entity_group": "COMPONENT",
          "word": "operational amplifier"
        },
        {
          "entity_group": "VENDOR",
          "word": "Texas Instruments"
        },
        {
          "entity_group": "DESIGN_PARAM",
          "word": "dual power supply"
        }
      ]
    }
    
  • Error Response (500):

    {
      "detail": "Error message explaining the failure."
    }
    

MCP (Model Context Protocol) Integration

The service uses fastapi-mcp to expose its core functionality as MCP operations. This allows AI agents or other MCP-compatible systems to directly call the NER functions as tools.

Exposed Operations

  • extract_entities: Corresponds to the POST /predict endpoint. Takes a text input and returns extracted entities.
  • get_all_entities: Corresponds to the GET /all_entities endpoint. Returns a list of all possible entity types.

Setup and Installation

  1. Clone the repository:

    git clone https://github.com/di37/nlp-fastapi-mcp-server.git
    cd nlp-fastapi-mcp-server
    
  2. Create and activate a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Windows, use `.venv\Scripts\activate`
    
  3. Install dependencies:

    pip install -r requirements.txt
    

Running the Application

To start the API server, run the following command:

python api_mcp.py

The server will be available at http://0.0.0.0:5152.

MCP Configuration

To connect to this service from an MCP client (like another AI agent), use the following configuration:

For Windsurf:

{
    "mcpServers": {
        "electrical-ner-mcp":{
            "serverUrl": "http://localhost:5152/mcp"
        }
    }
}

For Cursor:

{
    "mcpServers": {
        "electrical-ner-mcp":{
            "url": "http://localhost:5152/mcp",
            "transport": "streamable-http"
        }
    }
}

Claude Desktop still does not support url MCP server. Will update the documentation once it is supported.