mcp-langchain-agent
README.md
# mcp-langchain-agent
A **Model Context Protocol (MCP) server** exposing a small set of tools, paired with a **LangChain agent** that uses those tools to complete multi-step tasks.
> π **What this proves to a recruiter:** I can build agentic systems β tool use, MCP, multi-step planning β extending the kind of MCP server work happening on Adobe AEM today.
## What's in here
```
mcp-langchain-agent/
βββ mcp_server/ # MCP server that exposes tools via stdio
β βββ server.py # entrypoint, registers tools
β βββ tools.py # the actual tool implementations
β βββ schemas.py # JSON schemas for tool inputs/outputs
βββ agent/
β βββ client.py # LangChain agent that connects to the MCP server
β βββ chains.py # reusable prompt/chain definitions
βββ tests/
β βββ test_server.py
β βββ test_agent.py
βββ examples/
βββ run_demo.py # end-to-end demo of the agent solving a task
```
## The tools
The MCP server exposes three tools an LLM can call:
| Tool | What it does |
|---|---|
| `search_docs(query, top_k)` | BM25-ish keyword search over a local corpus of markdown notes |
| `get_doc(doc_id)` | Fetch the full text of a doc by id |
| `summarize(doc_id, max_words)` | Returns a short summary of a doc (LLM-backed) |
## The agent
The LangChain agent:
1. Receives a user task in natural language (e.g. *"Find what our handbook says about vacation policy and give me a 3-bullet summary"*)
2. Decides which tools to call, in what order
3. Calls the tools via the MCP client
4. Synthesises the answer from the tool outputs
Powered by `langchain-mcp-adapters` so the MCP tools become LangChain `Tool` objects β no glue code.
## Quickstart
### Prerequisites
- Python 3.11+
- An OpenAI or Anthropic API key
### Install
```bash
git clone https://github.com/adityapal26may/mcp-langchain-agent
cd mcp-langchain-agent
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
```
### Configure
```bash
export OPENAI_API_KEY=sk-...
# or
export ANTHROPIC_API_KEY=sk-ant-...
```
### Run the demo
```bash
python examples/run_demo.py
```
## Architecture
```
ββββββββββββββββββββ ββββββββββββββββββββββ
β LangChain Agent β βββββββΆ β MCP Server (stdio)β
β (client.py) β tools β (server.py) β
ββββββββββββββββββββ JSON βββββββββββ¬βββββββββββ
β² β
β βΌ
β ββββββββββββββββββββββ
β β Tool Implementationsβ
β β (tools.py) β
β βββββββββββ¬βββββββββββ
β β
ββββββββ synthesized answer βββββ
```
## Why MCP
MCP is becoming the **standard protocol for connecting LLMs to tools and data sources** β Anthropic, OpenAI, and major IDE vendors all support it. Building a server + client pair here is a direct demonstration of:
- Multi-step agentic reasoning
- Tool schema design (JSON Schema for inputs)
- Process-level service boundaries (the MCP server runs as a separate process)
## Tech Stack
- Python 3.11, FastAPI (for the HTTP wrapper demo)
- LangChain (`langchain`, `langchain-openai`, `langchain-anthropic`)
- MCP (`mcp` Python SDK, `langchain-mcp-adapters`)
- `rank-bm25` for keyword search
- `pytest` for tests
## Roadmap
- [ ] Streaming token output from the agent
- [ ] Persistent conversation memory
- [ ] Observability: log every tool call + token usage
- [ ] HTTP transport (in addition to stdio)
- [ ] Eval suite: 20+ tasks with expected tool-call sequences
## Author
Aditya Pal β [@adityapal26may](https://github.com/adityapal26may)
This server cannot be deployed
Maintenance
ActivitySlowing
ResponsivenessNo issues