Cohere MCP Server
Enables AI assistants to use Cohere's language models, embeddings, and reranking capabilities via the Model Context Protocol.
README
Cohere MCP Server
A Model Context Protocol (MCP) server that provides seamless integration with Cohere's AI platform. This server exposes Cohere's powerful language models, embeddings, and reranking capabilities through the MCP protocol, enabling AI assistants like Claude to leverage Cohere's tools.
Features
- Chat & Completion - Conversational AI with Command models (including command-a-03-2025)
- Embeddings - Generate semantic embeddings for search, RAG, and clustering
- Reranking - Improve search relevance for RAG systems
- Multilingual Chat - 23+ language support with Aya models
- Text Summarization - Condense long documents
- Classification - Few-shot text classification
- Streaming Support - Real-time response streaming for chat
Available Models
Command Models (Chat/Completion)
command-a-03-2025- Latest Command model for complex reasoningcommand-r-plus- Excellent for RAG and tool usecommand-r- Balanced performance and costcommand-light- Fast, lightweight model
Embedding Models
embed-english-v3.0- Best English embedding model (1024 dimensions)embed-multilingual-v3.0- 100+ language supportembed-english-light-v3.0- Lightweight English embeddingsembed-multilingual-light-v3.0- Lightweight multilingual
Rerank Models
rerank-english-v3.0- Best English rerankingrerank-multilingual-v3.0- Multilingual reranking support
Aya Models (Multilingual)
aya-expanse-32b- Powerful multilingual model (23+ languages)aya-expanse-8b- Efficient multilingual model
Installation
Prerequisites
- Python 3.10 or higher
- A Cohere API key (get one here)
Install from Source
- Clone or download this repository:
cd /home/<user>/Projects/cohere-mcp-server
- Install the package:
pip install -e .
- Set up your API key:
# Create a .env file in the project root
echo "COHERE_API_KEY=your-api-key-here" > .env
Or set it as an environment variable:
export COHERE_API_KEY="your-api-key-here"
Usage
Running the Server
Run the MCP server directly:
cohere-mcp
Or using Python:
python -m cohere_mcp.server
The server communicates via stdio and follows the MCP protocol specification.
Configuring with Claude Desktop
Add the following to your Claude Desktop configuration file:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"cohere": {
"command": "cohere-mcp",
"env": {
"COHERE_API_KEY": "your-api-key-here"
}
}
}
}
Or if using Python directly:
{
"mcpServers": {
"cohere": {
"command": "python",
"args": ["-m", "cohere_mcp.server"],
"env": {
"COHERE_API_KEY": "your-api-key-here"
}
}
}
}
Using with Other MCP Clients
Any MCP-compatible client can connect to this server. The server uses stdio transport and follows the MCP specification.
Available Tools
cohere_chat
Chat with Cohere's Command models for conversational AI and reasoning tasks.
Parameters:
message(string, required) - The user messagemodel(string) - Model to use (default: "command-a-03-2025")temperature(number) - Sampling temperature 0-1 (default: 0.7)max_tokens(number) - Maximum tokens to generate (default: 4096)system_prompt(string) - Optional system instructions
Example:
{
"message": "Explain quantum computing in simple terms",
"model": "command-a-03-2025",
"temperature": 0.7
}
cohere_chat_stream
Streaming version of chat for real-time responses.
Parameters: Same as cohere_chat
cohere_embed
Generate embeddings for semantic search, RAG, and clustering.
Parameters:
texts(array of strings, required) - Texts to embed (max 96 per request)model(string) - Embedding model (default: "embed-english-v3.0")input_type(string) - Type: "search_document", "search_query", "classification", or "clustering"
Example:
{
"texts": ["Document 1", "Document 2"],
"model": "embed-english-v3.0",
"input_type": "search_document"
}
cohere_rerank
Rerank documents based on relevance to a query (ideal for RAG systems).
Parameters:
query(string, required) - The search querydocuments(array of strings, required) - Documents to rerank (max 1000)model(string) - Rerank model (default: "rerank-english-v3.0")top_n(number) - Number of results to return (default: 10)
Example:
{
"query": "What is machine learning?",
"documents": ["Doc about ML", "Doc about cooking", "Doc about AI"],
"top_n": 5
}
cohere_aya_chat
Chat using multilingual Aya models (supports 23+ languages).
Parameters:
message(string, required) - User message in any supported languagemodel(string) - Aya model (default: "aya-expanse-32b")language(string) - Target response language (optional)temperature(number) - Sampling temperature (default: 0.7)max_tokens(number) - Maximum tokens (default: 4096)
cohere_summarize
Summarize text content.
Parameters:
text(string, required) - Text to summarizemodel(string) - Model to use (default: "command-r")length(string) - "short", "medium", or "long"format(string) - "paragraph" or "bullets"
cohere_classify
Classify texts based on example training data.
Parameters:
inputs(array of strings, required) - Texts to classifyexamples(array of objects, required) - Training examples with "text" and "label" keysmodel(string) - Model to use (default: "embed-english-v3.0")
Available Resources
cohere://models
Lists all available Cohere models with their capabilities, context lengths, and recommended use cases.
cohere://config
Shows current server configuration including default models and settings.
Configuration
The server can be configured via environment variables:
| Variable | Description | Default |
|---|---|---|
COHERE_API_KEY |
Your Cohere API key | Required |
COHERE_DEFAULT_CHAT_MODEL |
Default chat model | command-a-03-2025 |
COHERE_DEFAULT_EMBED_MODEL |
Default embedding model | embed-english-v3.0 |
COHERE_DEFAULT_RERANK_MODEL |
Default rerank model | rerank-english-v3.0 |
COHERE_TIMEOUT |
API request timeout (seconds) | 60 |
COHERE_MAX_RETRIES |
Maximum API retry attempts | 3 |
Development
Install Development Dependencies
pip install -e ".[dev]"
This installs testing and linting tools:
- pytest - Testing framework
- black - Code formatter
- ruff - Linter
- mypy - Type checker
Running Tests
pytest
Run with coverage:
pytest --cov=cohere_mcp --cov-report=html
Code Quality
Format code:
black src/ tests/
Lint code:
ruff check src/ tests/
Type check:
mypy src/
Project Structure
cohere-mcp-server/
├── src/
│ └── cohere_mcp/
│ ├── __init__.py # Package initialization
│ ├── config.py # Configuration management
│ ├── client.py # Cohere API client wrapper
│ └── server.py # MCP server implementation
├── tests/ # Test suite
│ ├── conftest.py
│ ├── test_config.py
│ ├── test_client.py
│ └── test_server.py
├── pyproject.toml # Project configuration
└── README.md # This file
Use Cases
Retrieval Augmented Generation (RAG)
- Embed documents: Use
cohere_embedwithinput_type="search_document" - Embed query: Use
cohere_embedwithinput_type="search_query" - Rerank results: Use
cohere_rerankto improve relevance - Generate response: Use
cohere_chatwith retrieved context
Semantic Search
- Index documents using
cohere_embed - Search with query embeddings
- Optionally rerank with
cohere_rerank
Multilingual Applications
Use cohere_aya_chat for conversations in:
- English, Spanish, French, German, Italian, Portuguese
- Arabic, Hebrew, Turkish
- Chinese, Japanese, Korean
- Hindi, Bengali, and many more
Troubleshooting
"Cohere client not initialized" error
Make sure you've set the COHERE_API_KEY environment variable:
export COHERE_API_KEY="your-key-here"
API Key Issues
- Verify your API key at https://dashboard.cohere.com/api-keys
- Ensure the key has proper permissions
- Check for any whitespace in the key value
Connection Issues
- Check your internet connection
- Verify Cohere API status
- Increase timeout with
COHERE_TIMEOUTenvironment variable
API Pricing
Refer to Cohere's pricing page for current API costs.
Resources
License
MIT License - See LICENSE file for details.
Support
For issues and questions:
- Cohere API issues: Cohere Support
- MCP Server issues: Open an issue in this repository
- MCP Protocol: MCP Documentation
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
Built with Cohere and Model Context Protocol
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。