Skip to content

matfonseca/remote_mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Remote MCP (Model Context Protocol) Server

A demonstration project showcasing a remote MCP server for apartment information retrieval, with a client that uses LangChain and OpenAI to create an interactive chatbot.

Overview

This project consists of two main components:

  1. MCP Server (remote_mcp/server.py): A FastMCP server that provides apartment information tools
  2. MCP Client (client_mcp/client.py): A LangChain-based chatbot client that connects to the remote MCP server

The server exposes apartment search functionality through the Model Context Protocol, while the client provides an interactive chat interface powered by OpenAI's GPT model.

Features

  • 🏠 Apartment Search: Get apartment listings for any city
  • 🤖 AI-Powered Chat: Interactive chatbot using OpenAI GPT-4
  • 🌐 Remote MCP: Server deployed remotely (Render.com)
  • FastMCP: High-performance MCP server implementation
  • 🔗 LangChain Integration: Seamless tool integration with LangGraph

Project Structure

remote_mcp/
├── pyproject.toml          # Poetry configuration and dependencies
├── poetry.lock            # Locked dependencies
├── README.md              # This file
├── remote_mcp/
│   ├── __init__.py
│   └── server.py          # MCP server implementation
└── client_mcp/
    └── client.py          # Interactive chatbot client

Prerequisites

  • Python 3.11+
  • Poetry (for dependency management)
  • OpenAI API key

Installation

  1. Clone the repository:

    git clone https://github.com/matfonseca/remote_mcp
    cd remote_mcp
  2. Install dependencies using Poetry:

    poetry install
  3. Set up environment variables: Create a .env file in the project root:

    touch .env

    Add your OpenAI API key to the .env file:

    OPENAI_API_KEY=your_openai_api_key_here
    

Usage

Running the MCP Server (Local Development)

To run the MCP server locally for development:

poetry run python remote_mcp/server.py

The server will start on http://0.0.0.0:8001 by default. You can customize the port by setting the PORT environment variable.

poetry run python client_mcp/client.py

This will start an interactive chat session where you can ask questions about apartments.

Example Interaction

MCP Chatbot Started!
Type your queries or 'quit' to exit.

Query: What apartments are available in New York?

Response:
Here are the available apartments in New York:
- Apartment 1: 2 bed, 1 bath, $1200/month
- Apartment 2: 3 bed, 2 bath, $1500/month  
- Apartment 3: 1 bed, 1 bath, $900/month

Query: quit

Available Tools

The MCP server exposes the following tools:

get_apartments_info(city: str)

  • Description: Get a list of apartments in a given city
  • Parameters:
    • city (str): The city to search for apartments
  • Returns: List of apartment descriptions with details like bedrooms, bathrooms, and rent

Configuration

Server Configuration

The server can be configured using environment variables:

  • PORT: Server port (default: 8001)
  • HOST: Server host (default: 0.0.0.0)

Client Configuration

To connect to a local server instead, modify the URL in client_mcp/client.py:

"url": "http://0.0.0.0:8001/mcp"

Dependencies

Core Dependencies

  • mcp ^1.17.0: Model Context Protocol implementation
  • langchain-mcp-adapters ^0.1.11: LangChain MCP integration
  • langchain ^0.3.27: LangChain framework
  • langchain-openai ^0.3.35: OpenAI integration for LangChain
  • langgraph ^0.6.10: Graph-based agent framework

Development Dependencies

  • python-dotenv: Environment variable management

Development

Running Tests

poetry run pytest

Code Formatting

poetry run black .
poetry run isort .

Linting

poetry run flake8

Deployment

The MCP server is currently deployed on Render.com at https://remote-mcp-mzug.onrender.com/mcp.

To deploy your own instance:

  1. Fork this repository
  2. Connect your Render.com account to your GitHub
  3. Create a new Web Service on Render
  4. Set the build command: poetry install
  5. Set the start command: poetry run python remote_mcp/server.py
  6. Configure environment variables as needed

Troubleshooting

Common Issues

  1. "Module not found" errors: Make sure you're running commands with poetry run prefix
  2. OpenAI API errors: Verify your API key is correctly set in the .env file
  3. Connection errors: Check that the remote server URL is accessible

Debug Mode

Enable debug logging by setting the log level in your environment:

export LOG_LEVEL=DEBUG

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

[Add your license information here]

Contact

For questions or support, please [add contact information].


This project demonstrates the power of Model Context Protocol for creating distributed AI tool ecosystems.

About

Example of remote mcp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages