Springing into AI - Detour - MCP Inspector

Problem

MCP Server is enriched with a lot of capabilities. As enterpris grade GenAI applications are developed, it is imperative to be able to test and improve upon in isolation. Would it not be amazing, if we had a tool offering allowing us the freedom to debug, diagnose, test and observer the interactions that occur ?

Solution

MCP Inspector is a nice UI utility tool that can empower the developer in refining their applications as it is being prepared for A grade quality deliverable. The utility tool is hoste on a github repo here. It allows us the ability to entier manually install the entire setup locally on our machine or the ability to run it as a docker container for quick getting started. Do note that if you running it with a setup of a docker container and your application is running locally, you may also have to switch to "host" network for the container to be communicating with the local application. 

docker run 
-p 6274:6274 
-p 6277:6277 
--network host 
ghcr.io/modelcontextprotocol/inspector:latest

Running it from a container, if we navigate to http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=<PROVIDED AUTH TOKEN> , we should be able to see the user interface as show below:


    In this tool, developers get the capabilities to test:
  • Transport communication: It allows us to choose from one of the following transport types that we develop our custom MCP server with:

  • Security: From a security point, MCP Servers currently support OAuth capability. Using MCP Inspector this can be done on their interface as follows:
  • MCP Message Exchanges: Once the connection is established above with the relevant chosen transport type and security, as developers we can also have insight into the actual JSON RPC Messages being exchanged adhering to MCP specification. As we interact with different capabilities, we can see the different commands and message content exchanges in form of request-response that can be useful for troubleshooting, diagnosing and debugging issues. 
  • Resources: This allows us to to view the resources that we would be offering from a server point of view in terms of its capabilities. As we know this can be static of dynamic in nature. MCP Inspector allow us to see the list of resources that would be exposed to the client, as well as the ability to interact with the individual resource. 

            From the figure above, "List Resources" allows us to list static resources, "Resource Templates", a list of dynamic resources and a content pane to view the actual selected resource. It is to be noted when we have a MCP client, it is upto the client how this is being represented to the end user.
  • Prompts: One of the other abilities on MCP server side where we can offer the user a set of pre-defined prompts and prompt templates for ease of offering enriched user experience. Using MCP Inspector we can see the list of prompts and the ability to interact with prompt templates should it be required.
  • Tools: As with prompts, Tools are another very powerful capability of MCP Server. It is afterall where we expose custom business functionality to the end user. This in real world would be invoked by the MCP Client. Using MCP Inspector we can test the various tools we offer in isolation
  • Elicitation: As our tools do their jobs, depending on the nature of tool we may require additional input from user for it to reach its completion. MCP Inspector allows us to test our elicitations. In the screen below, when an elicitation request is being detected, it will appear here. Based on the use-case we can then take relevant action for accept, deny or cancelling the request.
  • Sampling: As with elicitations, sampling allows by nature the MCP Server to request LLM for more analysis on the given subject. Using MCP Inspector we can see the relevant sampling being requested from our tool to LLM in its relevant section. 
             
  • Roots: This is the offering of MCP Server where we can define boundaries of resources that client can see. Example typically includes not having to expose entire path of resources but only certain limited restricted paths. Using MCP Inspector, we can view the listed roots.


Comments

Popular posts from this blog

Springing into AI - Part 4: LLM - Machine Setup

Springing into AI - Part 1: 1000 feet overview

Springing into AI - Part 2: Generative AI