Overview
This guide demonstrates how to integrate Explorium’s MCP (Model Context Protocol) server with LangGraph to build intelligent AI agents that can access Explorium’s business data enrichment capabilities. LangGraph provides a framework for building stateful, multi-actor applications with LLMs, making it perfect for creating sophisticated business intelligence workflows.Prerequisites
Before you begin, ensure you have:- Python 3.11 or higher
- An Explorium API key
- An Anthropic API key (or another LLM provider API key)
- A Python environment (Databricks, Jupyter, or local)
Installation
Install the required packages using pip:Quick Start
Here’s a minimal example to get you started:Core Components
1. Required Imports
Start by importing all necessary libraries:2. Define Configuration and State
Create the necessary data structures for your agent:3. System Prompt
Define a system prompt that guides your agent’s behavior:Complete Implementation
Here’s a full implementation of a LangGraph agent with Explorium MCP integration:Running the Agent
Create a function to run your LangGraph agent:Available Explorium Tools
The MCP integration provides access to the following Explorium tools:match-business
- Match and identify businessesfetch-businesses
- Retrieve business informationfetch-businesses-statistics
- Get business statisticsfetch-businesses-events
- Fetch business eventsenrich-business
- Enrich business data with additional attributesmatch-prospects
- Match prospect contactsfetch-prospects
- Retrieve prospect informationfetch-prospects-events
- Fetch prospect eventsfetch-prospects-statistics
- Get prospect statisticsenrich-prospects
- Enrich prospect dataautocomplete
- Autocomplete suggestions for field values
Security Best Practices
Environment Variables
Store your API keys as environment variables:Databricks Secrets
For Databricks environments, use the secrets management system:Alternative LLM Providers
While this guide uses Anthropic’s Claude, you can use other LLM providers:Advanced Features
Custom Tool Selection
Filter and select specific tools for your agent:Custom Message Handling
Implement custom logic for different message types:Error Handling
Implement comprehensive error handling:Batch Processing
Process multiple queries efficiently:Example Output
When running the agent with a query like “Find 10 product managers from Microsoft”, you’ll see:Troubleshooting
Authentication Errors
Problem:AuthenticationError: Error code: 401 - invalid x-api-key
Solution:
- Verify your Anthropic API key is valid and active
- Check the API key format (should start with
sk-ant-api03-
) - Ensure you’re using a valid model name:
- Claude:
claude-3-5-sonnet-20241022
,claude-3-opus-20240229
- OpenAI:
gpt-4
,gpt-4-turbo
- Claude:
Connection Issues
Problem: Cannot connect to MCP server Solution:- Verify your Explorium API key is correct
- Check the endpoint URL is exactly:
https://mcp.explorium.ai/mcp
- Test your network connectivity
- Ensure firewall rules allow HTTPS connections
Tool Loading Issues
Problem: No tools loaded or tools not working Solution:- Ensure you’re within an active MCP session context
-
Check the
langchain_mcp_adapters
version is up to date: - Verify the session is initialized before loading tools
API Reference
MCP Configuration
- Endpoint:
https://mcp.explorium.ai/mcp
- Transport: Streamable HTTP
- Authentication: API key in headers
- Headers Format:
{"api_key": "your-api-key"}
Support and Resources
- Explorium Support: Contact your Explorium representative
- API Documentation: Explorium Developer Portal
- LangGraph Documentation: LangGraph Docs
- LangChain Documentation: LangChain Docs
- MCP Specification: Model Context Protocol