Introduction to Model Context Protocol (MCP)
James Chapman
AI Curriculum Manager, DataCamp




get_book_by_title, get_authors_by_name, get_book_cover, get_book_by_id, ...from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
params = StdioServerParameters(
command="open-library-server",
args=[]
)
params = StdioServerParameters(command="open-library-server", args=[])async with stdio_client(params) as (reader, writer): async with ClientSession(reader, writer) as session: await session.initialize()response = await session.list_tools() print("Tools:", [t.name for t in response.tools]) result = await session.call_tool("get_book_by_title", {"title": "Dune"}) text = result.content[0].text print("Tool Call Result:", text)
Tools: ['get_book_by_title', 'get_authors_by_name', 'get_author_info', 'get_author_photo', 'get_book_cover', 'get_book_by_id']Tool Call Result: [ { "title": "Dune", "authors": [ "Frank Herbert" ], "first_publish_year": 1965, ... }, ...
Introduction to Model Context Protocol (MCP)