Lộ trình học›Claude API›Building with the Claude API Mở bản đồ

6.62 · Server inspector — Debug UI cho MCP

Bài viếtTrung cấp10 phút đọc

Build server → test end-to-end qua chatbot = slow loop:

Sau bài này, bạn sẽ
  1. Start MCP Inspector để test server
  2. Verify tools, prompts, resources qua UI
  3. Development workflow hiệu quả

Mở đầu: Test server không cần chatbot

  • Edit server
  • Restart app
  • Chat với Claude
  • Observe behavior

Inspector = web UI test server directly, skip Claude layer.

Start Inspector

mcp dev mcp_server.py

Output:

MCP Inspector starting on http://localhost:6277
Connected to mcp_server.py

Open browser → see dashboard.

Interface

┌────────────────────────────────────────────────┐
│  MCP Inspector                                 │
│                                                │
│  Server: mcp_server.py  [Connected ✓]          │
│                                                │
│  ┌──────────────────────────────────────────┐  │
│  │  Tabs:                                   │  │
│  │  [Resources] [Prompts] [Tools] [Logs]    │  │
│  └──────────────────────────────────────────┘  │
│                                                │
│  Tools:                                        │
│    - hello                                     │
│    - read_doc_contents                         │
│    - edit_document                             │
│                                                │
│  Click tool → see schema, test with params     │
│                                                │
└────────────────────────────────────────────────┘

Test tool

  1. Click Tools tab
  2. Click List Tools (refresh)
  3. Select tool, e.g., read_doc_contents
  4. Enter params: doc_id: "report.pdf"
  5. Click Run Tool
  6. See result
Result:
[TextContent type="text" text="This report describes Q3 performance..."]

Duration: 25ms

Rapid iteration.

Test prompts

Similar flow trong Prompts tab:

  • Select prompt
  • Fill params (e.g., doc_id: "report.pdf")
  • View generated messages

Verify interpolation correct.

Test resources

Resources tab:

  • Click List Resources
  • See resource URIs
  • Click resource → read content

Logs

Logs tab:

  • Shows server log output
  • Debug errors

Helpful when tool fails — see exception trace.

Dev workflow

1. Edit mcp_server.py
2. Save (auto-reload if supported)
3. Refresh Inspector → List Tools
4. Test tool qua Inspector
5. Check log for errors
6. Iterate

Much faster than full chatbot loop.

Testing complex scenarios

Sequence

Test tool chaining:

  1. edit_document(doc_id="report.pdf", old_str="Q3", new_str="Q4")
  2. read_doc_contents(doc_id="report.pdf") — verify change applied

Inspector show both results → confirm end-to-end.

Edge cases

  • Empty string input
  • Very long input
  • Invalid doc_id → verify error handling

Inspector catch these without chatbot complexity.

When NOT to use Inspector

Real agent behavior

Inspector is manual. To test "Claude uses tools correctly" — need chatbot.

Inspector = unit test. Chatbot = integration test.

Multi-tool chains

Claude decides dispatch. Inspector sequential manual. Chatbot shows emergent behavior.

Inspector caveat: UI changes

MCP Inspector under active dev. UI may differ screenshots. Core functionality (list/call) stable.

Anti-patterns

Only test via chatbot

Slow feedback loop.

Fix: Inspector first cho unit tests.

Inspector only

Miss emergent agent behavior (Claude choice of tools).

Fix: Both. Inspector + real chatbot.

Not checking logs

Tool fail silently, Inspector show "undefined behavior".

Fix: Check Logs tab when issue arise.

Áp dụng ngay

Bài tập: Test toàn bộ server (15 phút)

Start Inspector. For each tool bạn đã define:

  • List tools — verify name, description
  • Run tool với normal params
  • Run tool với edge case (empty, invalid)
  • Check Logs for any error

Goal: confident server robust trước khi integrate.

Tóm tắt bài học

Những điều cốt lõi
  • Inspector = browser UI test MCP server standalone.
  • mcp dev server.py to start.
  • Tabs: Tools, Prompts, Resources, Logs.
  • Fast dev loop: edit → reload → test in seconds.
  • Complement chatbot testing, không thay thế.
Kiểm tra nhanh1 câu hỏi · chọn đáp án để xem giải thích
    Bạn đã hoàn thành bài này chưa?Tiến độ lưu trên trình duyệt của bạn.