Skip to content

Latest commit

 

History

History
91 lines (70 loc) · 1.82 KB

File metadata and controls

91 lines (70 loc) · 1.82 KB

Running this sample

-1- Install the dependencies

dotnet restore

-3- Run the sample

dotnet run

-4- Test the sample

With the server running in one terminal, open another terminal and run the following command:

npx @modelcontextprotocol/inspector dotnet run

This should start a web server with a visual interface allowing you to test the sample.

Once the server is connected:

  • try listing tools and run add, with args 2 and 4, you should see 6 in the result.
  • go to resources and resource template and call "greeting", type in a name and you should see a greeting with the name you provided.

Testing in CLI mode

You can launch it directly in CLI mode by running the following command:

npx @modelcontextprotocol/inspector --cli dotnet run --method tools/list

This will list all the tools available in the server. You should see the following output:

{
  "tools": [
    {
      "name": "Add",
      "description": "Adds two numbers",
      "inputSchema": {
        "type": "object",
        "properties": {
          "a": {
            "type": "integer"
          },
          "b": {
            "type": "integer"
          }
        },
        "title": "Add",
        "description": "Adds two numbers",
        "required": [
          "a",
          "b"
        ]
      }
    }
  ]
}

To invoke a tool type:

npx @modelcontextprotocol/inspector --cli dotnet run --method tools/call --tool-name Add --tool-arg a=1 --tool-arg b=2

You should see the following output:

{
  "content": [
    {
      "type": "text",
      "text": "Sum 3"
    }
  ],
  "isError": false
}

![!TIP] It's usually a lot faster to run the inspector in CLI mode than in the browser. Read more about the inspector here.