Getting Started with Model Context Protocol By the end of this lesson, students should be able to: Authentication in MCP servers. MCP servers handle their own authentication with external services – the host and client do not see API keys or credentials. The server is the trust boundary. Patterns: The server should fail loudly at startup if required credentials are missing – not silently at tool call time. Meaningful error responses. Tool handlers should return errors that Claude can communicate to the user: @app.call_tool() Returning the error as a TextContent block allows Claude to surface it to the user with context, rather than the session crashing on an unhandled exception. Production server patterns. Complete server checklist before deployment. Enroll to continue this lesson. The preview above shows the lesson objectives and opening lesson content. Enroll to view the full lesson, complete the practice work, and take the lesson quiz.
Lesson 5: Connecting Claude to External Services via MCP
Lesson Objectives
Lesson Content
os.environ.get("GITHUB_TOKEN"))
async def call_tool(name: str, arguments: dict):
if name == "search_github":
try:
results = github_client.search(arguments["query"])
return [types.TextContent(type="text", text=format_results(results))]
except github.GithubException as e:
return [types.TextContent(
type="text",
text=f"GitHub search failed: {e.status} {e.data.get('message', 'Unknown error')}"
)]
