{"id":"d80faf4e-333c-43cd-b176-a0500b51d02f","slug":"aswego123-mcp-basic","kind":"mcp","name":"MCP-basic","summary":"","owner":"aswego123","repoUrl":"https://github.com/aswego123/MCP-basic","license":"GPL-3.0","licenseTier":"strong-copyleft","trust":"community","stars":0,"match":null,"fewStars":true,"format":"mcp","createdAt":"2025-09-17T17:19:14.000Z","addedAt":"2026-10-21T15:56:16.958Z","logoUrl":"https://avatars.githubusercontent.com/u/77005833?u=c92a26e5cf0bbb4d5e7a35e82df76b3878e3c94e&v=4","linkOnly":false,"collection":null,"skillPath":null,"categories":["utilities"],"tags":[],"runtime":"binary","local":true,"cloudCapable":false,"cloudCapability":"unknown","cloudReadyOnPlatform":false,"needsApiKey":false,"reviewed":false,"syncedAt":"2026-10-24T11:55:12.065Z","sample":false,"url":"https://conduits.dev/tools/aswego123-mcp-basic","language":"Python","transports":["stdio"],"install":{},"requirements":{"env":[],"upstreamMayCharge":false},"tools":null,"readme":"# MCP Server Langchain Project\r\n\r\nA demonstration project showcasing the integration of Model Context Protocol (MCP) servers with Langchain and LangGraph for creating AI agents that can interact with custom tools.\r\n\r\n## Project Overview\r\n\r\nThis project demonstrates how to:\r\n- Create MCP servers with custom tools (Math and Weather services)\r\n- Connect multiple MCP servers to a Langchain client\r\n- Use LangGraph to create reactive agents that can utilize MCP tools\r\n- Integrate with different LLM providers (Groq, Gemini)\r\n\r\n## Project Structure\r\n\r\n```\r\nMCPSERVERLangchain-main/\r\n├── server/\r\n│   ├── mathserver.py      # MCP server with math operations\r\n│   └── weather.py         # MCP server with weather information\r\n├── client/\r\n│   └── client.py          # Langchain client connecting to MCP servers\r\n├── main.py                # Main entry point\r\n├── pyproject.toml         # Project dependencies\r\n├── requirements.txt       # Python requirements\r\n└── README.md             # This file\r\n```\r\n\r\n## Features\r\n\r\n### MCP Servers\r\n\r\n1. **Math Server** (`server/mathserver.py`)\r\n   - Provides mathematical operations\r\n   - Tools: `add(a, b)` and `multiple(a, b)`\r\n   - Transport: stdio\r\n\r\n2. **Weather Server** (`server/weather.py`)\r\n   - Provides weather information\r\n   - Tools: `get_weather(location)`\r\n   - Transport: streamable-http\r\n\r\n### Client\r\n\r\nThe client (`client/client.py`) demonstrates:\r\n- Multi-server MCP client setup\r\n- Integration with LangGraph reactive agents\r\n- Tool invocation through natural language queries\r\n\r\n## Prerequisites\r\n\r\n- Python 3.13 or higher\r\n- API keys for LLM providers (Groq, Gemini)\r\n\r\n## Installation\r\n\r\n1. Clone the repository:\r\n```bash\r\ngit clone <repository-url>\r\ncd MCPSERVERLangchain-main\r\n```\r\n\r\n2. Install dependencies:\r\n```bash\r\npip install -r requirements.txt\r\n```\r\n\r\n3. Create a `.env` file in the project root with your API keys:\r\n```env\r\nGROQ_API_KEY=your_groq_api_key_here\r\nGEMINI_API_KEY=your_gemini_api_key_here\r\n```\r\n\r\n## Usage\r\n\r\n### Running the MCP Servers\r\n\r\n1. **Start the Weather Server** (in one terminal):\r\n```bash\r\ncd server\r\npython weather.py\r\n```\r\n\r\n2. **Start the Math Server** (in another terminal):\r\n```bash\r\ncd server\r\npython mathserver.py\r\n```\r\n\r\n### Running the Client\r\n\r\n1. **Run the client** (in a third terminal):\r\n```bash\r\ncd client\r\npython client.py\r\n```\r\n\r\nThe client will:\r\n- Connect to both MCP servers\r\n- Create a reactive agent using the specified LLM\r\n- Execute example queries for math and weather operations\r\n\r\n## Configuration\r\n\r\n### Environment Variables\r\n\r\n- `GROQ_API_KEY`: Your Groq API key for LLM access\r\n- `GEMINI_API_KEY`: Your Gemini API key for LLM access\r\n\r\n### Server Configuration\r\n\r\n- **Math Server**: Uses stdio transport for direct communication\r\n- **Weather Server**: Uses streamable-http transport on localhost:8000\r\n\r\n### Client Configuration\r\n\r\nThe client is configured to connect to:\r\n- Math server via stdio transport\r\n- Weather server via HTTP transport at `http://localhost:8000/mcp`\r\n\r\n## Example Queries\r\n\r\nThe client demonstrates these example queries:\r\n\r\n1. **Math Query**: \"what's (3 + 5) x 12?\"\r\n2. **Weather Query**: \"what is the weather in California?\"\r\n\r\n## Dependencies\r\n\r\n- `langchain-groq`: Groq LLM integration\r\n- `langchain-mcp-adapters`: MCP adapters for Langchain\r\n- `langgraph`: Reactive agent framework\r\n- `mcp`: Model Context Protocol implementation\r\n- `python-dotenv`: Environment variable management\r\n\r\n## Troubleshooting\r\n\r\n1. **Port Conflicts**: Ensure port 8000 is available for the weather server\r\n2. **API Keys**: Verify your API keys are correctly set in the `.env` file\r\n3. **Python Version**: Ensure you're using Python 3.13 or higher\r\n4. **Dependencies**: Run `pip install -r requirements.txt` if you encounter import errors\r\n\r\n## Contributing\r\n\r\n1. Fork the repository\r\n2. Create a feature branch\r\n3. Make your changes\r\n4. Submit a pull request\r\n\r\n## License\r\n\r\nThis project is licensed under the terms specified in the LICENSE file.\r\n"}