Learning about MCP

Learning about MCP

By WojciechMatuszewski GitHub

-

Overview

what is MCP Server Learning?

MCP Server Learning is a project focused on understanding and implementing the Model Context Protocol (MCP) for server-client interactions.

how to use MCP Server Learning?

To use this project, you need to implement the sampling and roots functionalities as outlined in the documentation. You can deploy the server using either STDIO or SSE transport methods.

key features of MCP Server Learning?

  • Implementation of transport methods (STDIO and SSE) for server-client communication.
  • Core primitives like Resources, Prompts, Tools, Sampling, and Roots to enhance server functionality.
  • Learning opportunity to write a server using Node.js without relying on external frameworks.

use cases of MCP Server Learning?

  1. Building a server that can handle various data resources for user queries.
  2. Creating a system that utilizes predefined prompts for user interactions.
  3. Developing tools that allow LLMs to perform actions on behalf of users.

FAQ from MCP Server Learning?

  • What are the transport methods available?

The project supports STDIO and SSE transport methods for server-client communication.

  • Can I use frameworks like Fastify?

While Fastify was considered, the project focuses on using Node.js directly for learning purposes.

  • What are the core primitives in MCP?

Core primitives include Resources, Prompts, Tools, Sampling, and Roots, each serving a specific function in the server architecture.

Content

Learning about MCP

TODO:

Learnings

  • There are two transport methods:

    • Via stdio. Here, you have to provide a path to a server binary client can use.

    • Via sse. Here, you have to provide a network address for the server.

      • This transport method seems more universal to me. It allows the server to be deployed separately than the client.
  • I really wanted to use fastify for the server, but I could not make it work with the existing SDK.

    • This is a great opportunity to learn how to write such server using only Node!
  • Core primitives that relate to MCP are:

    • Resources – You can think of these as data (like PDFs, database records and so on) that client can use to shape the correct response to the users query.

    • Prompts – Think of those as pre-defined prompts you sometimes see under the text box in "prompt to x" flows.

    • Tools – Those allow the LLM to perform actions on the user behalf. It is the server that calls the tool and responds with the result to the client. Clients job is to then pass the results to the LLM.

    • Sampling – To be honest, I'm unsure what those are yet.

    • Roots – Those define the "boundaries" of the server. For example, if your server exposes a tool that works with the file system, you could include specific directory in the "roots" so that the tool is "bounded" only to that directory.

    • Transports – Already wrote about them above. There is the STDIO and SSE transport. As for the messages, they are formatted via JSON-RPC 2.0.

  • I really like the fact that the SDK has error-handling built-in.

    • I can throw an error in the server tool callback function, and the client SDK will handle that, and respond accordingly.
No tools information available.
No content found.