MCP Employee API Server
A Model Context Protocol (MCP) server that provides tools for managing employee data through a REST API. This server exposes employee management operations as MCP tools that can be used by AI assistants and other MCP clients.
Features
Employee Management: Full CRUD operations for employee data
REST API Integration: Connects to a local employee API server
MCP Protocol: Exposes functionality through the Model Context Protocol
Async Operations: Built with async/await for optimal performance
Error Handling: Robust error handling for API requests
Available Tools
The server provides the following MCP tools:
get_employees()- Retrieve all employeesget_employee(id)- Get a specific employee by IDadd_employee(name, age)- Create a new employeeupdate_employee(id, name, age)- Update an existing employeedelete_employee(id)- Delete an employee by ID
Prerequisites
Python 3.13 or higher
A running employee API server at
http://localhost:8000
Installation
Clone the repository:
git clone https://github.com/JoseGarayar/mcp_test.git cd mcp_testClone the api employee repository:
git clone https://github.com/JoseGarayar/api_employees.gitInstall dependencies using uv:
uv sync
Usage
Running the MCP Server
Start the MCP server using stdio transport:
The server will run and listen for MCP protocol messages via stdin/stdout.
API Configuration
The server is configured to connect to a local API server at http://localhost:8000. You can modify the URL_BASE constant in main.py to point to a different API endpoint.
Example API Endpoints
The server expects the following API endpoints to be available:
GET /employees- List all employeesGET /employees/{id}- Get employee by IDPOST /employees- Create new employeePUT /employees/{id}- Update employeeDELETE /employees/{id}- Delete employee
Development
Project Structure
Dependencies
httpx- Async HTTP client for API requestsmcp[cli]- Model Context Protocol implementation
Development Dependencies
ruff- Python linter and formatter
Error Handling
The server includes comprehensive error handling:
Network timeouts (30 seconds)
HTTP error status codes
Invalid HTTP methods
Connection failures
All errors are gracefully handled and return None for failed operations.
License
This project is part of a test implementation for MCP server development.
local-only server
The server can only run on the client's local machine because it depends on local resources.
Enables AI assistants to manage employee data through a REST API with full CRUD operations. Provides tools to create, read, update, and delete employee records via the Model Context Protocol.