NitroStack Logo
/python
/sdk
/server

Server Concepts

Agent skill: nitrostack-python-mcp-app-architecture

Python NitroStack is modules + DI + a factory bootstrap. Do not use TypeScript @McpApp / @Module / Zod.

Bootstrap

Generated apps start from main.py:

Python
import asyncio
from nitrostack import McpApplicationFactory
from app_module import AppModule

async def main():
    app = await McpApplicationFactory.create(AppModule)
    await app.start()

if __name__ == "__main__":
    asyncio.run(main())

Optional @mcp_app on a class:

Python
from nitrostack import mcp_app, ServerConfig, module

@mcp_app(module=AppModule, server=ServerConfig(name="math-server", version="1.0.0"))
class App:
    pass

app = await McpApplicationFactory.create(App)

The factory initializes logging, the DIContainer, imported modules, tools/resources/prompts, then starts the transport.

Modules

@module(...) takes name, controllers, providers, imports, exports.

  • controllers — classes with @tool / @resource / @prompt
  • providers — injectable services
  • imports — other modules, ConfigModule, OAuthModule, …
  • exports — providers other modules may inject
Python
from nitrostack import module, ConfigModule
from modules.calculator.calculator_module import CalculatorModule
from health.system_health import SystemHealthCheck

@module(
    name="app",
    imports=[
        ConfigModule.for_root(env_file_path=".env", defaults={"PORT": "3000"}),
        CalculatorModule,
    ],
    providers=[SystemHealthCheck],
)
class AppModule:
    pass

Health checks

Python
from nitrostack import health_check

@health_check(name="system")
class SystemHealthCheck:
    async def check(self) -> dict:
        return {"ok": True}

Execution context

Every handler receives ExecutionContext: request_id, logger, metadata, auth, task, mcp_headers, and more. See Execution Context.

Next steps