📚

Understanding Model Context Protocol (mCP)

Apr 4, 2025

Lecture on mCP (Model Context Protocol)

Introduction to mCP

  • mCP stands for Model Context Protocol.
  • Initiative by Anthropic, known for Claude.
  • Aims to provide LLMs (Large Language Models) with access to various data sources.
  • Practical focus with minimal theory.

Example Problem

  • Attempting to use Claude to summarize the latest commits in a GitHub repository.
  • Initial issue: Claude doesn't have direct access or the ability to summarize commits due to knowledge cut-off.

Solution with mCP

  • Reconfigure Claude Desktop to use the mCP protocol.
  • mCP allows Claude to access data through designated tools, e.g., from GitHub.
  • Use case: Claude can now summarize commits after gaining access via mCP.

How mCP Works

  • Entities Involved:
    • Claude Desktop (Client/Host)
    • Actual LLM (Claude)
    • Data Source (GitHub in the example)
    • mCP Server (new entity)
  • mCP server acts as an intermediary, allowing data access.

mCP Server Functionality

  • Accesses external APIs (e.g., GitHub REST API) to gather data.
  • Has a "tools" endpoint that lists capabilities (e.g., list commits, create pull requests).
  • Implements functionalities to access data and return results.

Reference Implementations

  • The mCP Organization on GitHub provides reference servers for different data sources (File System, Google Drive, GitHub, etc.).
  • Each server lists tools it can execute, such as listing commits on GitHub.

Workflow with mCP

  1. Query Preparation:
    • Claude Desktop queries the mCP server for available tools.
    • Receives list of possible actions (e.g., list commits).
  2. Query Execution:
    • Claude Desktop sends the query and tools to the LLM (Claude).
    • LLM requests the use of a tool.
  3. Tool Execution:
    • mCP server executes the requested tool (e.g., list GitHub commits).
    • Returns data to Claude Desktop.
  4. Final Query to LLM:
    • Claude Desktop sends the data to Claude for summarization.

Configuration

  • Modify configuration files to link Claude Desktop with mCP servers.
  • Use Docker, npm commands, or other methods to run mCP servers.

Additional Features and Future Topics

  • mCP servers can do more than tools (e.g., sampling routes, template prompts).
  • Future episodes will cover implementing clients in various programming languages (Node.js, Java).

Conclusion

  • mCP provides a framework for enabling LLMs to interact with external data sources effectively.
  • Offers potential for creating more dynamic and agentic workflows.