MCPClient Python Application
implementation for interacting between an MCP server and an Ollama model
spirita1204
README
MCPClient Python Application
This is a Python client application designed to interact with an MCP (Model Context Protocol) server.
Features
- Asynchronous Communication: Uses
asyncio
for non-blocking communication between the client and server. - Customizable Server Scripts: The client can connect to both Python and JavaScript-based server scripts.
- Tool Management: Dynamically fetches and interacts with tools available on the connected server.
- Chat Interface: Provides a simple command-line interface to interact with the server in a conversational format.
- Tool Integration: Supports extracting JSON-formatted tool calls from server responses and executing them.
- Environment Variable Loading: Supports loading environment variables from a
.env
file using thedotenv
package.
Requirements
- Python 3.7 or higher
asyncio
library (included with Python)requests
for HTTP requests to the servermcp
(custom library for handling MCP communication)dotenv
for environment variable management
Setup
-
Clone the repository (or download the script files) to your local machine.
-
Install required dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the root directory to load necessary environment variables. For example:BASE_URL=http://localhost:11434 MODEL=llama3.2
-
Run the client with the path to the server script:
python client.py <server_script_path>
The server script can be a Python
.py
or JavaScript.js
file.
How It Works
- Connecting to the MCP Server: The client connects to the server via standard input/output channels, using the provided script (
.py
or.js
). - Processing Queries: The client sends user queries to the server and receives responses. Available tools are listed and can be called directly from the assistant’s replies.
- Tool Execution: If a response contains a valid tool call (in JSON format), the client extracts the call and triggers the respective tool on the server.
- Interaction: The client interacts with the server in a conversational format, displaying results from server tools and continuing the conversation.
Example Workflow
-
The user enters a query like:
Question: What is the weather today?
-
The client sends the query to the server, which responds with available tools and information.
-
If the server suggests using a weather tool, the client executes the tool with the necessary parameters and shows the result.
-
The client continues the conversation based on the new information returned by the tool. https://github.com/furey/mongodb-lens
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
MCP Package Docs Server
Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
@kazuph/mcp-taskmanager
Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.
Jira-Context-MCP
MCP server to provide Jira Tickets information to AI coding agents like Cursor

Linear MCP Server
A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Sequential Thinking MCP Server
This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.