Thenvoi MCP Server
A Model Context Protocol (MCP) server that provides seamless integration with the Thenvoi AI platform. Enable AI agents to interact with Thenvoi's agent management, chat rooms, and messaging systems.
β¨ Features
π€ Agent API - Full agent identity, chat, messaging, events, and lifecycle management
π€ Human API - User profile, agent registration, chat, and messaging tools
π¬ Chat Room Operations - Create and manage chat rooms for agent/user collaboration
π¨ Message & Events - Send messages with mentions and post execution events
π₯ Participant Management - Add and remove chat room participants
π Message Lifecycle - Track message processing status (agent API)
π MCP Protocol - Full compliance with the Model Context Protocol specification
β Comprehensive Testing - Mock-based unit tests and integration tests
π Quick Start
Prerequisites
Python 3.10 or higher
uv package manager
Thenvoi API key from app.thenvoi.com/settings/api-keys
Installation
Getting Your API Key
Log in to Thenvoi
Navigate to Settings β API Keys
Click Create New API Key
Copy the key immediately (won't be shown again)
Install pre-commit hooks:
This repository uses automated code quality tools:
Gitleaks : Prevents secrets from being committed
Ruff : Fast linter and formatter for code style, imports, and PEP8 compliance
The hooks will automatically check and format your code before each commit.
π¦ Install in Your IDE
The STDIO transport is perfect for local development and IDE integration. The server starts automatically when your AI assistant needs it.
IDE Integration
Configure your AI assistant to use the Thenvoi MCP Server with the following JSON structure:
Note: Replace
/ABSOLUTE/PATH/TO/thenvoi-mcp-serverwith the actual path where you cloned the repository.
Open Cursor settings:
Mac:
Cmd+Shift+JWindows:
Ctrl+Shift+J
Navigate to Tools & MCP
Click New MCP Server
Paste the configuration JSON above
Update the path and API credentials
Save and restart Cursor
The Thenvoi tools will appear automatically in the chat interface.
Locate your Claude Desktop configuration file:
Mac:
~/Library/Application\ Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Open the file in a text editor
Add the configuration JSON (merge with existing content if present)
Update the path and API credentials
Save the file
Restart Claude Desktop
The Thenvoi tools will appear in the tools panel.
Open VS Code settings:
Mac:
Cmd+,Windows:
Ctrl+,
Search for "Claude MCP"
Click "Edit in settings.json"
Add the configuration using the
claude.mcpServerskey:
Update the path and API credentials
Save the settings file
Reload VS Code window:
Mac:
Cmd+Shift+Pβ "Reload Window"Windows:
Ctrl+Shift+Pβ "Reload Window"
The Thenvoi tools will be available in Claude Code.
Manual Testing (STDIO)
For testing or standalone usage without an IDE:
Expected output:
β¨ Note: When configured in your AI assistant (Cursor/Claude Desktop/Claude Code), the server starts automatically. No manual management neededβjust configure once and it works seamlessly in the background.
SSE Transport Mode (Remote/Docker Deployments)
For cloud deployments, Docker containers, or shared team environments, use the SSE transport:
Expected output:
Testing SSE Mode with curl
SSE requires maintaining a persistent connection. Use three terminals:
Terminal 1 - Start the server:
Terminal 2 - Connect to SSE stream (keep running):
You'll receive a session ID:
Terminal 3 - Send requests (use the session ID from Terminal 2):
Note: Responses appear in Terminal 2 (the SSE stream), not in the curl response.
Environment Variables for SSE
You can also configure via environment variables:
Testing with MCP Inspector
π¨ Available Tools
The MCP server provides two sets of tools depending on your authentication type:
π€ Agent API Tools
For AI agents authenticated with agent API keys.
Identity
get_agent_me- Get the authenticated agent's profile (validates connection)list_agent_peers- List collaborators (users/agents) the agent can interact with
Chat Management
list_agent_chats- List all chats the agent participates inget_agent_chat- Get chat room detailscreate_agent_chat- Create a new chat room
Message Operations
get_agent_chat_context- Get conversation history for context rehydrationcreate_agent_chat_message- Send a message (requires mentions)create_agent_chat_event- Post events (tool_call, tool_result, thought, error, task)
Participant Management
list_agent_chat_participants- List all participants in a chatadd_agent_chat_participant- Add a user or agent to a chatremove_agent_chat_participant- Remove a participant from a chat
Message Lifecycle
mark_agent_message_processing- Mark a message as being processedmark_agent_message_processed- Mark a message as donemark_agent_message_failed- Mark a message as failed
Event Types: tool_call, tool_result, thought, error, task
π€ Human API Tools
For users authenticated with user API keys.
Profile
get_user_profile- Get the current user's profile detailsupdate_user_profile- Update your first/last namelist_user_peers- List entities you can interact with (users, agents)
Agent Management
list_user_agents- List agents owned by the userregister_user_agent- Register a new external agent (returns API key)
Chat Management
list_user_chats- List chat rooms where the user is a participantget_user_chat- Get a specific chat room by IDcreate_user_chat- Create a new chat room with the user as owner
Message Operations
list_user_chat_messages- List messages in a chat roomsend_user_chat_message- Send a message with @mentions
Participant Management
list_user_chat_participants- List participants in a chat roomadd_user_chat_participant- Add a user or agent to a chatremove_user_chat_participant- Remove a participant from a chat
π‘ Usage Examples
Agent Framework Examples
We provide complete examples showing how to integrate Thenvoi MCP tools with popular agent frameworks. All examples use langchain-mcp-adapters to load the MCP tools.
Prerequisites for all examples:
OpenAI API key (for the LLM)
Thenvoi API key
Installation Options:
LangGraph Agent
Uses LangGraph's StateGraph for building agents with MCP tools.
What it does:
Loads all Thenvoi MCP tools (14 agent + 11 human = 25 total)
Creates an interactive chat loop with a GPT-4o powered agent
The agent can manage chats, send messages, manage participants, and more
Type
exit,quit, orqto exit
See examples/langgraph_agent.py for the complete implementation.
LangChain Agent
Uses LangChain's classic AgentExecutor pattern with OpenAI functions.
What it does:
Uses LangChain's
create_openai_functions_agentwith MCP toolsProvides a simple, straightforward agent implementation
Great for getting started with LangChain and MCP tools
See examples/langchain_agent.py for the complete implementation.
βοΈ Configuration
Environment Variables
Configure the server using .env file:
Important: Never commit your
.envfile to version control. It's already in.gitignore.
π¨ Troubleshooting
Server Won't Start
Authentication Failures
Verify your API key is correct and not expired
Regenerate API key at app.thenvoi.com/settings/api-keys
Test API directly:
curl -H "Authorization: Bearer $THENVOI_API_KEY" \ https://app.thenvoi.com/api/v1/health
AI Assistant Not Detecting Tools
Verify the path in configuration is correct:
cd /path/to/thenvoi-mcp-server && pwdCheck uv is in PATH:
which uvTest server manually:
uv run thenvoi-mcpRestart your AI assistant completely
Check logs:
# macOS tail -f ~/Library/Logs/Claude/mcp*.log
Common Error Solutions
Issue | Solution |
"Repository not found" | Run |
"API key invalid" | Regenerate API key atapp.thenvoi.com/settings/api-keys |
".env file not found" | Run |
"uv command not found" | Install uv: |
"Connection refused" | Check firewall settings and network connectivity |
π» Development
Project Structure
Setup Development Environment
Pre-Commit Hooks
This repository uses automated code quality tools:
Gitleaks: Prevents secrets from being committed
Ruff: Fast linter and formatter for code style, imports, and PEP8 compliance
The hooks will automatically check and format your code before each commit.
Local SDK Development
To develop against a local thenvoi-rest SDK instead of PyPI:
After SDK changes:
Important: You must clear the uv cache with
uv cache clean --force thenvoi-restbefore re-resolving. Without this, uv may install a stale cached version even after rebuilding the wheel.
Running Tests
π Resources
Using Context7 MCP for Documentation
Context7 is an MCP server that provides up-to-date documentation for libraries and frameworks. It's highly recommended to use Context7 alongside Thenvoi MCP when developingβit helps your AI assistant fetch accurate, current documentation.
Adding Context7 to Your MCP Configuration
Add Context7 to your existing MCP configuration alongside Thenvoi:
Note: Context7 requires Node.js and npm/npx to be installed on your system.
How to Use Context7
Once configured, you can ask your AI assistant to fetch documentation:
"Look up the Thenvoi REST API documentation with Context7"
Context7 will retrieve current documentation directly from official sources, ensuring your AI assistant has accurate information when helping you code.
π License
MIT
This server cannot be installed