テスト、調査、強化
Inspectorで検証し、アクセスを厳格に制限します。
「テスト、調査、強化」はCoddyKit上の無料MCP Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMCP Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 MCP Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
From Working to Trustworthy
Your server runs, but is it ready for real use? Now you test, inspect, and harden it so it behaves under pressure and bad input. 🛡️
Smoke Test First
Start with a quick smoke test: does the server boot and list its tools without errors? Catching a broken start early saves hours of confusion.
Open the Inspector
Launch the MCP Inspector with the dev command. It gives you a visual panel to click through every tool, resource, and prompt by hand.
# In your project folder:
# uv run mcp dev server.pyClick Each Tool
In the Inspector, call each tool with sample inputs. Seeing the live result confirms the wiring works before any AI client ever connects.
Read a Resource
Try fetching a resource by its uri in the Inspector. If the right note comes back, your path variable and read logic are doing their job.
Test the Bad Path
Feed each tool obviously bad input: empty strings, huge numbers, missing fields. A solid server answers with a clear error, never a crash.
Return Errors, Not Stack Traces
Wrap risky work and raise a clean message. The model can read a friendly error and recover, but a raw traceback only confuses it.
@mcp.tool()
def get_note(note_id: int) -> str:
if note_id < 1:
raise ValueError("note_id must be a positive integer")
return read(note_id)Validate Before Acting
Check arguments at the top of each tool. Rejecting bad values early keeps your backend safe and your error messages specific and useful.
Apply Least Privilege
Give each tool only the access it truly needs. Least privilege means a search tool can read but never delete, shrinking the blast radius.
Guard Destructive Actions
For anything irreversible, demand a clear flag or confirmation. A guard on delete stops a hasty model call from wiping real data. ⚠️
@mcp.tool()
def delete_note(note_id: int, confirm: bool = False) -> str:
if not confirm:
return "Set confirm=True to delete."
remove(note_id)
return "Deleted."Add Automated Tests
Write a few pytest cases that call your functions directly. Automated checks let you change code later and instantly know nothing broke.
Quick Check
Let us confirm the hardening idea.
Recap
You tested with the Inspector, validated inputs, applied least privilege, and guarded destructive actions. Your server is now ready for the real world. 🎯
よくある質問
「テスト、調査、強化」レッスンは無料ですか?
はい。「テスト、調査、強化」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、MCP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 MCP Academyコースには全4レッスンが含まれています。
「テスト、調査、強化」で何を学びますか?
Inspectorで検証し、アクセスを厳格に制限します。 ブラウザで直接実行するハンズオンコードでMCP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
MCP Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのMCP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。
「テスト、調査、強化」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このMCP Academyレッスンでコードを書いて実行できますか?
はい。すべてのMCP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。