How to build mcp server

2025/12/20 Blog

How to build mcp server ?

https://docs.astral.sh/uv/getting-started/installation/

PS> powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

PS> uv -help  #Check if the installation was successful

PS> uv init mymcp
PS> cd .\mymcp\
PS> uv venv #Create virtual environment
PS> . .venv\Scripts\activate
PS> uv add mcp[cli] #Add mcp dependencies

demo.py

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("mcpdemo")

@mcp.tool()
def get_excel():
    """Get test file content"""
    str = ""
    file = r'E:\\test.xlsx'
    with open(file, 'r', encoding='utf-8') as f:
        str = f.read()
        print(str)
    return str

if __name__ == "__main__":
    # Initialize and run the server
    # mcp.run(transport='stdio')
    print("hello, mcp")
    get_excel()

Run mcp

PS> mcp dev demo.py

Debug

Web brower open http://127.0.0.1:6274

Search

    Welcome to follow my WeChat account

    elishateng

    Table of Contents