Content
# Metaso MCP Server
Metaso MCP (Model Context Protocol) Server, based on Metaso AI search engine, provides AI search, webpage content reading, and AI Q&A functions for large language models.
## Features
- **🔍 AI Search**: Supports various search scopes including webpages, documents, academic papers, images, videos, and podcasts
- **📖 Webpage Reading**: Extracts complete webpage content, supporting Markdown and JSON output formats
- **💬 AI Q&A**: Provides search-enhanced intelligent Q&A, supporting multiple AI models
- **🔒 Security Verification**: Includes URL safety checks, API key verification, and input length limits
- **🚀 High Performance**: Features a built-in retry mechanism, connection pooling, and error handling
## Installation
### Building from Source
```bash
# Clone the project
git clone https://github.com/csrts/metaso-mcp
cd metaso-mcp
# Install dependencies
npm install
# Build the project
npm run build
```
## Configuration
### Environment Variables
| Variable Name | Required | Default Value | Description |
|--------------|----------|---------------|-------------|
| `METASO_API_KEY` | ✅ | - | Metaso API key (format: mk-[32 characters]) |
| `METASO_BASE_URL` | ❌ | `https://metaso.cn` | API base URL |
| `METASO_TIMEOUT` | ❌ | `30000` | Request timeout (milliseconds) |
| `METASO_DEBUG` | ❌ | `false` | Enable debug logging |
### Obtaining API Key
1. Visit [Metaso Official Website](https://metaso.cn)
2. Register an account and obtain an API key
3. Set environment variable:
```bash
export METASO_API_KEY="mk-YOUR_API_KEY_HERE"
```
## MCP Client Configuration
See details at -> [MCP-CONFIG](https://github.com/csrts/metaso-mcp/blob/main/MCP-CONFIG.md)
### Claude Desktop
Add the following to Claude Desktop's configuration file:
```json
{
"mcpServers": {
"metaso": {
"command": "node",
"args": ["/path/to/metaso-mcp-server/dist/index.js"],
"env": {
"METASO_API_KEY": "mk-YOUR_API_KEY_HERE"
}
}
}
}
```
### Development Mode
```json
{
"mcpServers": {
"metaso": {
"command": "npx",
"args": ["-y", "tsx", "/path/to/metaso-mcp-server/src/index.ts"],
"env": {
"METASO_API_KEY": "mk-YOUR_API_KEY_HERE",
"METASO_DEBUG": "true"
}
}
}
}
```
## Available Tools
### 1. metaso_search - AI Search
Searches internet content, supporting various search scopes.
**Parameters**:
- `query` (required): Search query content
- `scope` (optional): Search scope, supports `webpage`, `document`, `scholar`, `image`, `video`, `podcast`
- `page` (optional): Page number (mutually exclusive with size)
- `size` (optional): Number of results (mutually exclusive with page)
- `include_summary` (optional): Whether to include AI summary (default true)
- `include_row_content` (optional): Whether to include original content (default false)
**Example**:
```json
{
"query": "latest developments in artificial intelligence",
"scope": "scholar",
"size": 10,
"include_summary": true
}
```
### 2. metaso_reader - Webpage Reading
Reads the complete content of a specified webpage.
**Parameters**:
- `url` (required): URL of the webpage to read
- `format` (optional): Return format, supports `markdown`, `json` (default markdown)
**Example**:
```json
{
"url": "https://example.com/article",
"format": "markdown"
}
```
### 3. metaso_chat - AI Q&A
Converses with Metaso AI assistant, obtaining search-enhanced intelligent responses.
**Parameters**:
- `query` (required): Question or prompt content
- `model` (optional): AI model, supports `fast`, `fast_thinking`, `ds-r1` (default fast)
- `scope` (optional): Search scope, supports `document`, `scholar`, `video`, `podcast`
- `format` (optional): Response format, supports `chat_completions`, `simple` (default chat_completions)
- `stream` (optional): Enable streaming output (default false)
**Example**:
```json
{
"query": "explain the basic principles of quantum computing",
"model": "ds-r1",
"scope": "scholar"
}
```
## Development
### Project Structure
```
metaso-mcp/
├── src/
│ ├── index.ts # Main entry file
│ ├── server.ts # MCP server implementation
│ ├── tools/ # Tool implementations
│ │ ├── search.ts # Search tool
│ │ ├── reader.ts # Read tool
│ │ └── chat.ts # Q&A tool
│ ├── types/ # Type definitions
│ │ └── requests.ts # Request and response types
│ └── utils/ # Utility functions
│ ├── config.ts # Configuration management
│ └── http-client.ts # HTTP client
├── tests/ # Test files
└── dist/ # Compilation output
```
### Development Commands
```bash
# Run in development mode
npm run dev
# Build the project
npm run build
```
### Running Tests
```bash
# Run all tests
npm test
# Run specific test
npm test -- search.test.ts
# Watch mode
npm run test:watch
```
## Troubleshooting
### Common Errors
1. **Configuration validation failed**
```
Configuration validation failed: apiKey: Required
```
**Solution**: Ensure `METASO_API_KEY` environment variable is set
2. **API key format error**
```
Invalid API key format. Expected format: mk-[32 alphanumeric characters]
```
**Solution**: Check API key format
3. **Network connection error**
```
Network error: Unable to connect to Metaso API
```
**Solution**: Check network connection and API base URL setting
### Debug Mode
Enable debug logging for more information:
```bash
export METASO_DEBUG=true
```
## Security
- 🔐 API key managed through environment variables
- 🚫 Blocks access to private IPs and localhost
- 📏 Query content length limit
- 🔍 URL security verification
- 🚨 Sensitive information logging masked
## License
MIT License
## Contribution
Feel free to submit issues and pull requests!
## Changelog
### v1.0.0
- Initial version release
- Supports AI search, webpage reading, AI Q&A functions
- Complete MCP protocol compatibility
- Security and error handling