Gen-AI Developer Classroom notes 09/May/2026

Anti-pattern

  • Never generate MCP server from Rest APIs
you already have api's now you an mcp server that does not mean
generate mcp from api using some generators

FastMCP – Python library for building mcp servers

Lets create mcp server for our library

  • install nvm
# search for 
# windows
winget nvm
# brew
brew nvm
  • Install nodejs
nvm install 24
nvm use 24
node --version
npm --version
  • Install mcp inspector
# optional
npm install -g npm@11.14.1
  • Create a new folder library-mcp
uv init .
uv add mcp mcp[cli]
# activate virtual env
.venv/Scripts/activate
source ./.venv/bin/activate
  • Create a file called as server.py with following code
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("library-mcp-server")

@mcp.tool("add_book")
def add_book(title: str, author: str, year: int) -> str:
    """Add a book to the library."""
    return f"Added book '{title}' by {author} ({year})"


def main():
    # Initialize and run the server
    mcp.run(transport="stdio")

if __name__ == '__main__':
    main()

  • Now from cli run mcp dev server.py
It might ask intially about npm package say est

Preview
Preview

By continuous learner

enthusiastic technology learner

Leave a Reply

Discover more from Direct AI Powered By Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading