This project consists of two main components: a research server that handles paper retrieval and a chatbot client that interacts with the research server using the Model Context Protocol (MCP).
mcp_project/
├── research_server.py # Server component for paper retrieval
├── mcp_chatbot.py # Client chatbot component
├── .venv/ # Virtual environment directory
└── papers/ # Directory for downloaded papers
- Python 3.x
- UV package manager
- Node.js and NPM (for the inspector)
- Navigate to the project directory:
cd mcp_project_prompt_resources- Initialize with UV:
uv init- Create and activate virtual environment:
uv venv
source .venv/bin/activate- Install required dependencies:
uv add mcp arxiv
uv pip install -r requirements.txt- Launch the inspector:
npx @modelcontextprotocol/inspector uv run research_server.py-
When prompted to install packages, type
y -
Configure the Inspector:
- Open the provided inspector address in your browser
- Under configuration, specify the Inspector Proxy Address
- Follow the Inspector UI Instructions for detailed configuration steps
- Navigate to File > Open > L4 > mcp_project
- Papers will be stored in the papers/ directory
- Use
Ctrl+Cin the terminal to stop the inspector
- Python 3.x
- UV package manager
- Active virtual environment from server setup
- Navigate to the project directory:
cd mcp_project_prompt_resources- Activate the virtual environment:
source .venv/bin/activate- Install additional dependencies:
uv add anthropic python-dotenv nest_asyncio- Start the chatbot:
uv run mcp_chatbot.py- Interact with the chatbot through the command line
- Type
quitto exit the chatbot
- Navigate to File > Open > L5 > mcp_project to access downloaded papers
The chatbot requires the following environment variables:
ANTHROPIC_API_KEY: Your Anthropic API key for Claude access
- Ensure the server is running before starting the chatbot
- Keep track of API usage and paper downloads
- The server and client components should be run in separate terminals
- Make sure to properly close both applications when done
The research server organizes papers in the following structure:
papers/- Root directory for all research papers{topic_name}/- Folders for each research topic (e.g. ai_interpretability, llm_reasoning)papers_info.json- JSON file containing metadata about papers in that topic
Resources in MCP are read-only data endpoints similar to GET endpoints in REST APIs. The research server exposes two main resources:
-
List of available topic folders:
- URI:
papers://folders - Returns list of available research topics
- URI:
-
Papers information under a specific topic:
- URI:
papers://{topic} - Returns paper metadata for the specified topic
- Dynamic URI where {topic} is specified at runtime
- URI:
The server provides customizable prompt templates using the @mcp.prompt() decorator. These templates can be used to generate structured prompts for specific use cases like paper searches.
The chatbot supports the following special commands:
@folders- List all available research topics@topic- Get papers information for a specific topic
/prompts- List all available prompt templates/prompt <name> <arg1=value1>- Execute a specific prompt with arguments
The chatbot has been updated with new methods to handle these features:
-
connect_to_server:- Requests available resources and prompt templates
- Stores resource URIs and prompt names
-
chat_loop:- Processes special commands (@folders, @topic, /prompts, /prompt)
- Routes commands to appropriate handlers
-
New Methods:
get_resource: Handles resource requestsexecute_prompt: Processes prompt template executionlist_prompts: Shows available prompt templates
Remember to check the complete implementation in the mcp_project folder for detailed usage examples.
Make sure to interact with the chatbot. Here are some query examples:
- @folders
- @ai_interpretability
- /prompts
- /prompt generate_search_prompt topic=history num_papers=2