Skip to content

【Memory Leak】Under pressure testing, there will be a memory leak until OOM (Out of Memory) occurs. #941

@BobLiu20

Description

@BobLiu20

Description

Server code:

from fastmcp import FastMCP

mcp = FastMCP("My MCP Server")

@mcp.tool
def greet(name: str) -> str:
    return f"Hello, {name}!"

if __name__ == "__main__":
    mcp.run(transport="streamable-http")

Client code(with a while loop):

import asyncio
from fastmcp import FastMCP, Client

async def call_tool(name: str):
    async with Client("http://127.0.0.1:8000/mcp") as client:
        result = await client.call_tool("greet", {"name": name})
        print(result)

while True:
    asyncio.run(call_tool("Bob"))

Issue

Memory will keep increasing until OOM (Out Of Memory) occurs.

Image

Example Code

see above

Version Information

fastmcp version is 2.9.0

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions