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.
This project consists of two main components:
- MCP Server (
remote_mcp/server.py): A FastMCP server that provides apartment information tools - 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.
- 🏠 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
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
- Python 3.11+
- Poetry (for dependency management)
- OpenAI API key
-
Clone the repository:
git clone https://github.com/matfonseca/remote_mcp cd remote_mcp -
Install dependencies using Poetry:
poetry install
-
Set up environment variables: Create a
.envfile in the project root:touch .env
Add your OpenAI API key to the
.envfile:OPENAI_API_KEY=your_openai_api_key_here
To run the MCP server locally for development:
poetry run python remote_mcp/server.pyThe 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.pyThis will start an interactive chat session where you can ask questions about apartments.
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
The MCP server exposes the following tools:
- 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
The server can be configured using environment variables:
PORT: Server port (default: 8001)HOST: Server host (default: 0.0.0.0)
To connect to a local server instead, modify the URL in client_mcp/client.py:
"url": "http://0.0.0.0:8001/mcp"mcp ^1.17.0: Model Context Protocol implementationlangchain-mcp-adapters ^0.1.11: LangChain MCP integrationlangchain ^0.3.27: LangChain frameworklangchain-openai ^0.3.35: OpenAI integration for LangChainlanggraph ^0.6.10: Graph-based agent framework
python-dotenv: Environment variable management
poetry run pytestpoetry run black .
poetry run isort .poetry run flake8The MCP server is currently deployed on Render.com at https://remote-mcp-mzug.onrender.com/mcp.
To deploy your own instance:
- Fork this repository
- Connect your Render.com account to your GitHub
- Create a new Web Service on Render
- Set the build command:
poetry install - Set the start command:
poetry run python remote_mcp/server.py - Configure environment variables as needed
- "Module not found" errors: Make sure you're running commands with
poetry runprefix - OpenAI API errors: Verify your API key is correctly set in the
.envfile - Connection errors: Check that the remote server URL is accessible
Enable debug logging by setting the log level in your environment:
export LOG_LEVEL=DEBUG- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
[Add your license information here]
For questions or support, please [add contact information].
This project demonstrates the power of Model Context Protocol for creating distributed AI tool ecosystems.