LangSearch MCP Server

LangSearch MCP Server

Provides access to LangSearch's Web Search and Semantic Rerank APIs for AI assistants. It enables web searching with advanced filtering and reranking of documents based on semantic relevance.

Category
Visit Server

README

LangSearch MCP Server

A Model Context Protocol (MCP) server that provides access to LangSearch's Web Search API and Semantic Rerank API. This server enables AI assistants to perform web searches and rerank search results based on semantic relevance.

Features

  • Web Search: Search the web with advanced filtering options (freshness, result count, summaries)
  • Semantic Rerank: Rerank documents based on semantic relevance to a query

Tools

1. langsearch_web_search

Search the web using LangSearch's Web Search API.

Parameters:

  • query (string, required): The search query
  • freshness (string, optional): Filter results by freshness - "noLimit" (default), "onLimit", "day", "week", "month"
  • summary (boolean, optional): Include full summaries in results (default: true)
  • count (number, optional): Number of results to return (1-50, default: 10)

Returns:

  • Structured search results with titles, URLs, snippets, and optional summaries
  • Query context and metadata

2. langsearch_semantic_rerank

Rerank documents based on semantic relevance to a query.

Parameters:

  • query (string, required): The search query to compare against documents
  • documents (array of strings, required): List of document texts to rerank
  • top_n (number, optional): Number of top results to return (default: all documents)
  • return_documents (boolean, optional): Whether to include document text in response (default: true)

Returns:

  • Reranked documents with relevance scores (0-1 scale)
  • Original document indices and optional text content

Installation

  1. Clone or download this repository
  2. Install dependencies:
npm install
  1. Build the project:
npm run build
  1. Copy .env.example to .env and add your LangSearch API key:
cp .env.example .env
  1. Edit .env and set your API key:
LANGSEARCH_API_KEY=your-api-key-here

Getting a LangSearch API Key

Visit LangSearch to sign up and obtain an API key.

Usage

With Claude Desktop

Add the server 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": "node",
      "args": [
        "/absolute/path/to/langsearch-mcp-ts/dist/index.js"
      ],
      "env": {
        "LANGSEARCH_API_KEY": "your-api-key-here"
      }
    }
  }
}

Replace /absolute/path/to/langsearch-mcp-ts with the actual path to this project directory.

After configuration, restart Claude Desktop. The LangSearch tools will be available in your conversations.

Standalone Mode

Standalone Mode

Development Mode

Run the server in development mode with auto-reload:

npm run dev

Production Mode

Build and run the compiled server:

npm run build
npm start

Testing with MCP Inspector

Test the server using the MCP Inspector:

npm run inspector

Then select "stdio" transport and provide the path to the server executable.

Configuration

The server uses environment variables for configuration:

  • LANGSEARCH_API_KEY (required): Your LangSearch API key
  • LANGSEARCH_BASE_URL (optional): Custom API base URL (default: https://api.langsearch.com)

Example Usage

Web Search Example

{
  "name": "langsearch_web_search",
  "arguments": {
    "query": "latest developments in AI",
    "freshness": "week",
    "summary": true,
    "count": 5
  }
}

Semantic Rerank Example

{
  "name": "langsearch_semantic_rerank",
  "arguments": {
    "query": "climate change solutions",
    "documents": [
      "Renewable energy is the future of power generation.",
      "The stock market reached new highs today.",
      "Carbon capture technology shows promise in reducing emissions."
    ],
    "top_n": 2,
    "return_documents": true
  }
}

API References

Error Handling

The server implements comprehensive error handling:

  • Invalid API keys return clear error messages
  • Network errors are caught and reported
  • Input validation ensures correct parameter types and ranges
  • All errors are returned with isError: true flag

TypeScript

This server is written in TypeScript with full type safety. All API responses and tool parameters are properly typed using zod schemas for runtime validation.

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured