Skip to content

[BUG] UnboundLocalError: cannot access local variable 'param_desc' where it is not associated with a value #99

Closed as duplicate of#94
@ElieTaillard

Description

@ElieTaillard

Describe the bug
When starting my app I got this error: UnboundLocalError: cannot access local variable 'param_desc' where it is not associated with a value

This is the stack trace:

2025-04-22 18:14:12 - application:get_app - INFO: Initializing MCP integration Process SpawnProcess-1: Traceback (most recent call last): File "C:\Users\elie.taillard\AppData\Local\Programs\Python\Python313\Lib\multiprocessing\process.py", line 313, in _bootstrap self.run() ~~~~~~~~^^ File "C:\Users\elie.taillard\AppData\Local\Programs\Python\Python313\Lib\multiprocessing\process.py", line 108, in run self._target(*self._args, **self._kwargs) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\elie.taillard\AppData\Local\pypoetry\Cache\virtualenvs\mcp-open-deep-research-9SAXCza8-py3.13\Lib\site-packages\uvicorn\_subprocess.py", line 80, in subprocess_started target(sockets=sockets) ~~~~~~^^^^^^^^^^^^^^^^^ File "c:\Users\elie.taillard\AppData\Local\pypoetry\Cache\virtualenvs\mcp-open-deep-research-9SAXCza8-py3.13\Lib\site-packages\uvicorn\server.py", line 66, in run return asyncio.run(self.serve(sockets=sockets)) ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\elie.taillard\AppData\Local\Programs\Python\Python313\Lib\asyncio\runners.py", line 195, in run return runner.run(main) ~~~~~~~~~~^^^^^^ File "C:\Users\elie.taillard\AppData\Local\Programs\Python\Python313\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ File "C:\Users\elie.taillard\AppData\Local\Programs\Python\Python313\Lib\asyncio\base_events.py", line 719, in run_until_complete return future.result() ~~~~~~~~~~~~~^^ File "c:\Users\elie.taillard\AppData\Local\pypoetry\Cache\virtualenvs\mcp-open-deep-research-9SAXCza8-py3.13\Lib\site-packages\uvicorn\server.py", line 70, in serve await self._serve(sockets) File "c:\Users\elie.taillard\AppData\Local\pypoetry\Cache\virtualenvs\mcp-open-deep-research-9SAXCza8-py3.13\Lib\site-packages\uvicorn\server.py", line 77, in _serve config.load() ~~~~~~~~~~~^^ File "c:\Users\elie.taillard\AppData\Local\pypoetry\Cache\virtualenvs\mcp-open-deep-research-9SAXCza8-py3.13\Lib\site-packages\uvicorn\config.py", line 441, in load self.loaded_app = self.loaded_app() ~~~~~~~~~~~~~~~^^ File "C:\Users\elie.taillard\OneDrive - Magellan Partners\Documents\GitHub\Mcp.OpenDeepResearch\app\web\application.py", line 40, in get_app mcp = FastApiMCP(app, name="MCP Open Deep Research") File "c:\Users\elie.taillard\AppData\Local\pypoetry\Cache\virtualenvs\mcp-open-deep-research-9SAXCza8-py3.13\Lib\site-packages\fastapi_mcp\server.py", line 150, in __init__ self.setup_server() ~~~~~~~~~~~~~~~~~^^ File "c:\Users\elie.taillard\AppData\Local\pypoetry\Cache\virtualenvs\mcp-open-deep-research-9SAXCza8-py3.13\Lib\site-packages\fastapi_mcp\server.py", line 161, in setup_server all_tools, self.operation_map = convert_openapi_to_mcp_tools( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ openapi_schema, ^^^^^^^^^^^^^^^ describe_all_responses=self._describe_all_responses, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ describe_full_response_schema=self._describe_full_response_schema, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "c:\Users\elie.taillard\AppData\Local\pypoetry\Cache\virtualenvs\mcp-open-deep-research-9SAXCza8-py3.13\Lib\site-packages\fastapi_mcp\openapi\convert.py", line 243, in convert_openapi_to_mcp_tools if param_desc: ^^^^^^^^^^ UnboundLocalError: cannot access local variable 'param_desc' where it is not associated with a value 

To Reproduce
This is my application.py:

"""Module for FastAPI application factory.""" import os import logging from fastapi import FastAPI from fastapi_mcp import FastApiMCP from app.api.endpoints.deep_search import router as deep_search_router from app.core.config import settings from app.web.observability import ObservabilityConfig def get_app() -> FastAPI: """  Factory function to create and configure the FastAPI application.   Returns:  FastAPI: Configured application instance.  """ logger = logging.getLogger("uvicorn") app = FastAPI( title="MCP Open Deep Research", description="FastAPI exposing LangChain deep search functionality via MCP", version="0.1.0", ) # Setup observability observability = ObservabilityConfig(app) observability.setup_all() # Include routers app.include_router( deep_search_router, prefix=settings.API_PREFIX, tags=["deep-search"] ) # Initialize MCP integration logger.info("Initializing MCP integration") mcp = FastApiMCP(app, name="MCP Open Deep Research") mcp.mount() @app.get("/", tags=["root"]) async def root(): """  Root endpoint.  """ return { "message": "Welcome to the MCP Open Deep Research API", "docs": f"{settings.API_PREFIX}/docs", "mcp": f"{settings.MCP_PREFIX}", } return app

System Info
This si my pyproject.toml:

[tool.poetry.dependencies] python = "^3.13" fastapi = "^0.115.12" uvicorn = "^0.34.2" fastapi-mcp = "^0.3.2" langchain = "^0.3.23" langchain-openai = "^0.3.14" open-deep-research = "^0.0.10" python-dotenv = "^1.1.0" pydantic = "^2.11.3" pydantic-settings = "^2.9.1" tavily-python = "^0.5.4" 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions