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 docker container and your application running locally, you may also have to switch to "host" network for the container to be communicating with the local application. A sample user interface of the tool running is 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.
In the figure above, we can see the sample list of prompts our MCP server is offering, and in case of prompt template the ability to ask the user for required input and using that as a parameter in the prompt templated when in real world having a client would relay onto the LLM.
- 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
The figure above shows a sample tool implementation developed for playground where MCP server lists the tools on the left side. The right side shows a sample tool selected for execution. In this particular case since the tool requires some information, it is a parameterised tool.
- 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.
The above is a sample shot captured when we ran the designed tool. When that occurs the tool required further input from user. A sample elicitation section being requested is shown above using MCP Inspector. How awesome is that to be able to test that with interaction without a dependency on the client.
- 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 done 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
Post a Comment