LangSearch MCP Server

LangSearch MCP Server

An MCP server that provides web search and semantic reranking capabilities using the LangSearch API. It enables searching billions of web documents with AI-optimized results and reordering them based on semantic relevance scores.

Category
访问服务器

README

LangSearch MCP Server

A Model Context Protocol (MCP) server that provides web search and semantic reranking capabilities using the LangSearch API.

Features

  • Web Search: Search billions of web documents with AI-optimized results

    • Full page summaries
    • Freshness filtering (day, week, month)
    • Customizable result count
    • Machine-readable structured output
  • Semantic Reranking: Improve search accuracy with deep semantic understanding

    • Reorder documents by semantic relevance
    • Relevance scores (0-1 scale)
    • Better than traditional keyword/vector search
    • Top-N filtering

Installation

Prerequisites

Setup

  1. Clone or navigate to the repository:
cd langsearch-mcp-python
  1. Install dependencies:
uv sync
  1. Configure your API key:
cp .env.example .env
# Edit .env and add your LANGSEARCH_API_KEY

Usage

Testing with MCP Inspector

Test the server interactively:

uv run mcp dev main.py

This opens the MCP Inspector where you can:

  • Browse available tools
  • Test tool invocations
  • View structured responses

Installing to Claude Desktop

Install the server for use with Claude Desktop:

uv run mcp install main.py

Follow the prompts to configure the installation.

Manual Installation in Claude Desktop

Add to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "langsearch": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/langsearch-mcp-python",
        "run",
        "main.py"
      ],
      "env": {
        "LANGSEARCH_API_KEY": "your_api_key_here"
      }
    }
  }
}

Running as HTTP Server

For remote access, run as an HTTP server:

# In main.py, change the last line to:
if __name__ == "__main__":
    mcp.run(transport="streamable-http")

Then run:

uv run main.py

Access at http://localhost:8000/mcp

Tools

web_search

Search the web for information across billions of documents.

Parameters:

  • query (string, required): Search query
  • count (integer, default=10): Number of results (1-50)
  • summary (boolean, default=true): Include full page summaries
  • freshness (string, default="noLimit"): Filter by freshness
    • "noLimit": All results
    • "day": Last 24 hours
    • "week": Last 7 days
    • "month": Last 30 days

Returns: Structured data with:

  • Total result count
  • Web pages with title, URL, snippet, summary
  • Original query

Example:

{
  "query": "latest AI developments 2026",
  "count": 5,
  "summary": true,
  "freshness": "week"
}

semantic_rerank

Rerank documents based on semantic relevance to a query.

Parameters:

  • query (string, required): Search query for ranking
  • documents (array[string], required): List of document texts to rerank
  • top_n (integer, optional): Return only top N results
  • model (string, default="langsearch-reranker-v1"): Reranker model

Returns: Structured data with:

  • Reranked documents with indices
  • Relevance scores (0-1, higher = more relevant)
  • Model used

Example:

{
  "query": "machine learning algorithms",
  "documents": [
    "Deep learning is a subset of machine learning...",
    "The history of neural networks dates back...",
    "Random forests are ensemble learning methods..."
  ],
  "top_n": 2
}

Development

Project Structure

langsearch-mcp-python/
├── main.py              # MCP server implementation
├── pyproject.toml       # Project dependencies
├── uv.lock             # Locked dependencies
├── .env.example        # Example environment variables
├── .gitignore          # Git ignore rules
└── README.md           # This file

Running Tests

# Test with MCP Inspector
uv run mcp dev main.py

# Test individual tools
uv run python -c "
from main import web_search
import asyncio
result = asyncio.run(web_search('Python programming', count=3))
print(result)
"

Error Handling

The server provides clear error messages for:

  • Missing API key
  • Invalid parameters
  • API errors
  • Network issues

Errors are returned as structured exceptions with descriptive messages.

API Reference

For detailed API documentation, see:

Environment Variables

Variable Required Description
LANGSEARCH_API_KEY Yes Your LangSearch API key

License

MIT

Support

For issues and questions:

Contributing

Contributions are welcome! Please ensure:

  • Type hints are used throughout
  • Docstrings follow the existing format
  • Error handling is comprehensive
  • Tests pass with uv run mcp dev

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选