MCPClient Python Application

MCPClient Python Application

implementation for interacting between an MCP server and an Ollama model

spirita1204

Developer Tools
Visit Server

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 the dotenv package.

Requirements

  • Python 3.7 or higher
  • asyncio library (included with Python)
  • requests for HTTP requests to the server
  • mcp (custom library for handling MCP communication)
  • dotenv for environment variable management

Setup

  1. Clone the repository (or download the script files) to your local machine.

  2. Install required dependencies:

    pip install -r requirements.txt
    
  3. Create a .env file in the root directory to load necessary environment variables. For example:

    BASE_URL=http://localhost:11434
    MODEL=llama3.2
    
  4. 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

  1. Connecting to the MCP Server: The client connects to the server via standard input/output channels, using the provided script (.py or .js).
  2. 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.
  3. 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.
  4. Interaction: The client interacts with the server in a conversational format, displaying results from server tools and continuing the conversation.

Example Workflow

  1. The user enters a query like:

    Question: What is the weather today?
    
  2. The client sends the query to the server, which responds with available tools and information.

  3. If the server suggests using a weather tool, the client executes the tool with the necessary parameters and shows the result.

  4. The client continues the conversation based on the new information returned by the tool. https://github.com/furey/mongodb-lens

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
MCP Package Docs Server

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.

Featured
Local
TypeScript
Claude Code MCP

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.

Featured
Local
JavaScript
@kazuph/mcp-taskmanager

@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.

Featured
Local
JavaScript
Linear MCP Server

Linear MCP Server

Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.

Featured
JavaScript
mermaid-mcp-server

mermaid-mcp-server

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Featured
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP server to provide Jira Tickets information to AI coding agents like Cursor

Featured
TypeScript
Linear MCP Server

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.

Featured
JavaScript
Sequential Thinking MCP Server

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.

Featured
Python