MCP ExplorerExplorer

Vllm With Mcp

@juna-99on a year ago
1 MIT
FreeCommunity
AI Systems
AI-powered vLLM Multi-Agent system with a connection hub (MCP style!)

Overview

What is Vllm With Mcp

vLLM-with-MCP is an AI-powered multi-agent system that utilizes the Model Context Protocol (MCP) to enhance language models’ understanding and response generation by dynamically providing contextual information from real-world sources.

Use cases

Use cases for vLLM-with-MCP include answering complex queries with up-to-date information, generating contextually relevant content, and providing intelligent responses in chatbots and virtual assistants.

How to use

To use vLLM-with-MCP, send a POST request to the /generate endpoint with a JSON payload containing your prompt. The server will enrich the prompt with context from web searches and return the language model’s response.

Key features

Key features of vLLM-with-MCP include real-time information retrieval using LinkUp, integration with local vLLM model servers, and a lightweight FastAPI implementation that allows for easy deployment and interaction.

Where to use

vLLM-with-MCP can be used in various fields such as customer support, content generation, educational tools, and any application requiring enhanced natural language understanding and generation.

Content

🧠 MCP Server (Model Context Protocol)

The MCP Server is a lightweight microservice that connects real-world information (like web search results) to language models (LLMs) to improve prompt understanding and response generation. This pattern enables you to dynamically provide context to LLMs before asking them a question.

📌 What is MCP?

MCP (Model Context Protocol) is a design pattern, not a library. It describes how to build applications that:

  1. Receive a user prompt
  2. Enrich the prompt with context (from web search, databases, documents, etc.)
  3. Send the enriched prompt to an LLM (like OpenAI, Claude, or vLLM)
  4. Return the LLM’s response

This project implements MCP as a FastAPI server.


⚙️ What This MCP Server Does

This particular server:

  • Accepts prompts at a REST endpoint (/generate)
  • Uses LinkUp to do web search and fetch real-time information
  • Sends enriched prompt + context to a local vLLM model server
  • Returns the model’s generated response

🗂️ Folder Structure

.
├── mcp_server.py     # Main MCP server implementation
├── test_client.py    # (Optional) Simple test client to interact with your MCP server
├── requirements.txt  # Python dependencies
├── .env              # API keys and secrets

🥪 Example Usage

Send a POST request to your MCP server:

curl -X POST http://localhost:8091/generate \
  -H "Content-Type: application/json" \
  -d '{"prompt": "What is the future of quantum computing?"}'

Response:

{
  "response": "Quantum computing is expected to..."
}

📥 Prerequisites

Make sure your environment has:

  • Python 3.10+
  • Access to vLLM (running on localhost:8000)
  • A working LinkUp API key

🔧 Installation & Setup

1. Clone This Repo

git clone https://github.com/your-org/mcp-server.git
cd mcp-server

2. Install Requirements

pip install -r requirements.txt

3. Set Up .env File

Create a .env file with your LinkUp API key:

LINKUP_API_KEY=your-linkup-api-key-here

🚀 Run the MCP Server

python mcp_server.py

Should show something like:

INFO:     Uvicorn running on http://0.0.0.0:8091

🧠 How the Code Works

# 1. Accept prompt
@app.post("/generate")
def generate_response(request: PromptRequest):
    prompt = request.prompt

    # 2. Get real-time web context from LinkUp
    search_results = perform_web_search(prompt)

    # 3. Combine context with user prompt
    full_prompt = f"{search_results}\n\nUser Prompt: {prompt}"

    # 4. Call vLLM for response
    model_output = call_vllm(full_prompt)

    return {"response": model_output}

👤 Streamlit UI (Optional)

Run this for a simple web interface:

streamlit run app.py --server.address 0.0.0.0

If you’re on a cloud container (like AI Stack), forward the port to view in a browser:

kubectl port-forward pod/<your-pod-name> 8501:8501

🧩 What’s Next?

You can customize this server to:

  • Use other context sources (e.g., PDF, vector DB)
  • Switch models (OpenAI, Claude, Gemini)
  • Handle multi-turn conversations

📚 Credits


🧠 Summary

This MCP server gives your LLM the eyes and ears it needs by pulling in real-world info — making your AI smarter, more accurate, and more up-to-date.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers