mcp-server-assignment

tw-mk/mcp-server-assignment

3.1

If you are the rightful owner of mcp-server-assignment and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

This repository contains a Model Context Protocol (MCP) server that provides cryptocurrency data using the CoinGecko API.

Tools
2
Resources
0
Prompts
0

Crypto MCP Server

This repository contains a Model Context Protocol (MCP) server that exposes cryptocurrency data from the public CoinGecko API. It includes:

  • a Python MCP client for invoking the server’s tools over stdio, and
  • a Groq LLM agent that uses those tools via OpenAI‑style function calling.

What is MCP?

Model Context Protocol (MCP) is an open protocol that lets AI apps connect to external tools and data in a consistent way. This server implements MCP tools that provide cryptocurrency market data.

Project Structure

  • mcp_server.py — MCP server implementation with cryptocurrency tools
  • mcp_client.py — Minimal Python helper that launches the MCP server and calls its tools
  • groq_mcp_agent.py — Groq LLM‑powered agent demonstrating tool calling via the MCP server
  • requirements.txt — Python dependencies

Tools exposed by the MCP server

1) get_price(coin, currency="usd")

Returns the current price of a cryptocurrency in the target currency.

Parameters:

  • coin (required): Cryptocurrency id (e.g., "bitcoin", "ethereum")
  • currency (optional): Target currency (default: "usd")

Conceptual example (tool call):

  • name: get_price
  • args: { coin: "bitcoin", currency: "usd" }

2) get_market_data(coin)

Returns price, market cap rank, and 24h price change.

Conceptual example (tool call):

  • name: get_market_data
  • args: { coin: "ethereum" }

Setup

Prerequisites

  • Python 3.9 or higher
  • pip or virtualenv (recommended)

Installation

  1. Clone this repository (or navigate to the project directory)

  2. Create and activate a virtual environment

python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. (Optional, only for Groq agent) Set your Groq API key
  • Create a .env file in the project root:
GROQ_API_KEY=your_groq_api_key_here
  • Or set it as an environment variable:
export GROQ_API_KEY=your_groq_api_key_here

Usage

Run the MCP server (optional)

You can run the server directly (clients will usually start it automatically):

python mcp_server.py

The server listens on stdio for MCP protocol messages.

Use the Python MCP client

The client helpers in mcp_client.py will start the server automatically and call tools. Run the example script to query both tools:

python mcp_client.py

You should see the current price and market data for Bitcoin.

Use the Groq LLM agent with MCP tools

The agent lets a Groq model decide when to call tools provided by the MCP server.

python groq_mcp_agent.py "Give me Bitcoin market data and current price in USD"

The agent will route any tool calls to the MCP client helpers, which talk to the server over stdio.

Integrating with other MCP‑aware clients

If your external MCP client needs a command to launch this server, configure it with:

command: python
args: ["mcp_server.py"]

Notes

  • The server uses the public CoinGecko API; rate limiting may apply.
  • Tool names and signatures are: get_price(coin, currency="usd"), get_market_data(coin).
  • Files and commands referenced above match this repository’s layout as of 2025‑11‑24.