MCP ExplorerExplorer

Modelcontextprotocol Agent Example

@patsabon 10 months ago
1 MIT
FreeCommunity
AI Systems
A German agent using Model Context Protocol to provide LLM tools.

Overview

What is Modelcontextprotocol Agent Example

ModelContextProtocol-Agent-Example is a demonstration application that utilizes the Model Context Protocol (MCP) to provide tools to a language model (LLM). It features a simple agent that operates in German, leveraging the MCP to enhance its capabilities.

Use cases

Use cases include creating a German-speaking virtual assistant, conducting automated research in German, and providing real-time information retrieval for German-speaking users.

How to use

To use the ModelContextProtocol-Agent-Example, first install the required dependencies using either ‘poetry install’ or ‘pip install -e .’. Start the MCP server with ‘python mcp_example/mcp_server.py’. Set the OpenAI API endpoint and key as environment variables, then launch the agent with ‘python -m mcp_example’.

Key features

Key features include a web search tool, a Wikipedia search tool, and a function to retrieve the current daytime. The agent communicates in German and utilizes OpenAI’s GPT-4o-mini for responses.

Where to use

This application can be used in fields such as natural language processing, AI-driven customer support, and educational tools where multilingual capabilities are beneficial.

Content

Model Context Protocol

Model Context Protocol (MCP) is a standardized way to provides tools to an LLM.

Application

This demo showcases a simple agent application (in german language) that uses the Model Context Protocol to provide tools to an LLM.

The tools are provided through a server which can be found at mcp_example/mcp_server.py.
These contain a web search, a wikipedia search and a function for the current daytime.

The MCP client is located at mcp_example/mcp_client.py and can connect to the server.

The agent, which uses the MCPClient to connect to the MCP server is located at mcp_example/mcp_agent.py.
It contains a german agent, which answers questions in german language using OpenAI GPT-4o-mini.

Requirements

Install the requirements:

#poetry
poetry install

#or with pip
pip install -e .

The MCP server needs to be started before the agent can be used. The server can be started with the following command:

python mcp_example/mcp_server.py

The agent uses the OpenAI API, for which the endpoint and api key need to be set as environment variables.

OPENAI_ENDPOINT=<your_openai_endpoint>
OPENAI_API_KEY=<your_openai_api_key>

Afterwards, the agent can be started with the following command:

python -m mcp_example

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers