Prospectio MCP API
A FastAPI-based application that implements the Model Context Protocol for lead prospecting, allowing users to retrieve business leads from different data sources like Mantiks through a clean architecture.
README
Prospectio MCP API
A FastAPI-based application that implements the Model Context Protocol (MCP) for lead prospecting. The project follows Clean Architecture principles with a clear separation of concerns across domain, application, and infrastructure layers.
🏗️ Project Architecture
This project implements Clean Architecture (also known as Hexagonal Architecture) with the following layers:
- Domain Layer: Core business entities and logic
- Application Layer: Use cases, ports (interfaces), and strategies
- Infrastructure Layer: External services, APIs, and framework implementations
📁 Project Structure
prospectio-api-mcp/
├── pyproject.toml # Poetry project configuration
├── poetry.lock # Poetry lock file
├── README.md # This file
└── src/
├── main.py # FastAPI application entry point
├── config.py # Application configuration settings
├── domain/ # Domain layer (business entities)
│ ├── entities/
│ │ └── leads.py # Lead, Company, and Contact entities
│ └── logic/ # Domain business logic (empty)
├── application/ # Application layer (use cases & ports)
│ ├── ports/ # Abstract interfaces (ports)
│ │ └── leads/
│ │ └── get_leads.py # ProspectAPIPort interface
│ ├── strategies/ # Strategy pattern implementations
│ │ └── leads/
│ │ ├── strategy.py # Abstract strategy base class
│ │ └── mantiks.py # Mantiks-specific strategy
│ └── use_cases/ # Application use cases
│ └── leads/
│ └── get_leads.py # GetLeadsContactsUseCase
└── infrastructure/ # Infrastructure layer (external concerns)
├── api/ # HTTP API routes
│ └── prospect_routes.py # FastAPI routes & MCP tools
└── services/ # External service adapters
└── mantiks.py # Mantiks API implementation
🔧 Core Components
Domain Layer (src/domain/)
Entities (src/domain/entities/leads.py)
Contact: Represents a business contact with name, email, and phoneCompany: Represents a company with name, industry, size, and locationLeads: Aggregates companies and contacts for lead data
Application Layer (src/application/)
Ports (src/application/ports/leads/get_leads.py)
ProspectAPIPort: Abstract interface defining the contract for prospect data sourcesfetch_leads(): Abstract method for fetching lead data
Use Cases (src/application/use_cases/leads/get_leads.py)
GetLeadsContactsUseCase: Orchestrates the process of getting leads from different sources- Accepts a source identifier and a port implementation
- Uses strategy pattern to delegate to appropriate strategy based on source
Strategies (src/application/strategies/leads/)
GetLeadsStrategy: Abstract base class for lead retrieval strategiesMantiksStrategy: Concrete implementation for Mantiks data source- Delegates to the injected port to fetch leads
Infrastructure Layer (src/infrastructure/)
API Routes (src/infrastructure/api/prospect_routes.py)
- FastAPI Router: RESTful API endpoints
- MCP Integration: Model Context Protocol tools registration
get_leads(source: str): Endpoint that accepts a source parameter and returns lead data- Maps source to appropriate service implementation
- Handles error cases with proper HTTP status codes
Services (src/infrastructure/services/mantiks.py)
MantiksAPI: Concrete implementation ofProspectAPIPort- Currently returns mock data for development/testing
- Can be extended to integrate with actual Mantiks API
🚀 Application Entry Point (src/main.py)
The FastAPI application is configured with:
- Lifespan Management: Properly manages MCP session lifecycle
- Dual Protocol Support:
- REST API at
/rest/v1/ - MCP protocol at
/prospectio/
- REST API at
- Router Integration: Includes prospect routes for lead management
⚙️ Configuration (src/config.py)
Environment-based configuration using Pydantic Settings:
Config: General application settings (MASTER_KEY, ALLOWED_ORIGINS)MantiksConfig: Mantiks API-specific settings (API_BASE, API_KEY)- Environment Loading: Automatically finds and loads
.envfiles
📦 Dependencies (pyproject.toml)
Core Dependencies
- FastAPI (0.115.14): Modern web framework with automatic API documentation
- MCP (1.10.1): Model Context Protocol implementation
- Pydantic (2.10.3): Data validation and serialization
- HTTPX (0.28.1): HTTP client for external API calls
Development Dependencies
- Pytest: Testing framework
🔄 Data Flow
- HTTP Request: Client makes request to
/rest/v1/leads/{source} - Route Handler:
get_leads()function receives source parameter - Service Mapping: Source is mapped to appropriate service (e.g., MantiksAPI)
- Use Case Execution:
GetLeadsContactsUseCaseis instantiated with source and service - Strategy Selection: Use case selects appropriate strategy based on source
- Port Execution: Strategy calls the port's
fetch_leads()method - Data Return: Lead data is returned through the layers back to client
🎯 Design Patterns
1. Clean Architecture
- Clear separation of concerns
- Dependency inversion (infrastructure depends on application, not vice versa)
2. Strategy Pattern
- Different strategies for different lead sources
- Easy to add new lead sources without modifying existing code
3. Port-Adapter Pattern (Hexagonal Architecture)
- Ports define interfaces for external dependencies
- Adapters implement these interfaces for specific technologies
4. Dependency Injection
- Services are injected into use cases
- Promotes testability and flexibility
🔧 Extensibility
Adding New Lead Sources
- Create new service class implementing
ProspectAPIPortininfrastructure/services/ - Add new strategy class extending
GetLeadsStrategyinapplication/strategies/leads/ - Register the new strategy in
GetLeadsContactsUseCase.strategiesdictionary - Add service mapping in
prospect_routes.py
Adding New Endpoints
- Add new routes in
infrastructure/api/directory - Create corresponding use cases in
application/use_cases/ - Define new ports if external integrations are needed
🏃♂️ Running the Application
-
Install Dependencies:
poetry install -
Set Environment Variables: Create a
.envfile with required configuration -
Run the Application:
poetry run uvicorn src.main:app --reload -
Access APIs:
- REST API:
http://localhost:8000/rest/v1/leads/mantiks - API Documentation:
http://localhost:8000/docs - MCP Endpoint:
http://localhost:8000/prospectio/mcp/sse
- REST API:
🧪 Testing
The project structure supports easy testing:
- Unit Tests: Test individual components in isolation
- Integration Tests: Test the interaction between layers
- Mock Services: Use mock implementations for external dependencies
📝 License
Apache 2.0 License
👥 Author
Yohan Goncalves yohan.goncalves.pro@gmail.com
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.