Standalone Server Mode
Relevant source files
The following files were used as context for generating this wiki page:
Standalone Server Mode is a specialized execution state for the mbbank-mcp application that enables the Model Context Protocol (MCP) server to operate over HTTP using Server-Sent Events (SSE). Unlike the default stdio transport mode, which is designed for local process communication (e.g., within Claude Desktop), Standalone Server Mode allows the server to be hosted on a network interface, providing remote accessibility and integration with web-based clients.
In this mode, the application leverages uvicorn as the ASGI server and starlette to manage routes and middleware. It exposes two primary endpoints: one for standard SSE communication and another for streamable HTTP requests. This mode is activated via the --sse command-line flag and requires the configuration of host and port parameters.
Sources: README.md:46-56, mbbank_mcp/main.py:32-68
Architecture and Transport Mechanisms
The standalone server relies on the FastMCP framework to bridge MBBank API functionalities with MCP-compliant interfaces. When executed with the --sse flag, the server transitions from a standard input/output stream to a networked architecture.
Server Components
The following diagram illustrates the component architecture during Standalone Server Mode:
The server integrates multiple layers: the CLI handles configuration, uvicorn provides the server runtime, and starlette manages the web application structure.
Sources: mbbank_mcp/main.py:32-68, pyproject.toml:13-21
Transport Endpoints
When initialized, the server provides two distinct endpoints for client interaction:
- SSE Endpoint (
/sse): Used for the Server-Sent Events transport. - Streamable HTTP Endpoint (
/mcp): Used for streamable HTTP communication.
Sources: mbbank_mcp/main.py:47-53
Configuration and Initialization
The standalone server is configured through command-line arguments or environment variables. The initialization process involves authenticating with MBBank before starting the network listener.
Configuration Parameters
| Parameter | CLI Flag | Env Variable | Default | Description |
|---|---|---|---|---|
| Username | --username | MBBANK_USERNAME | None | MBBank account username |
| Password | --password | MBBANK_PASSWORD | None | MBBank account password |
| Host | --host | N/A | localhost | Network interface to bind |
| Port | --port | N/A | 3000 | Port for the HTTP server |
| Mode | --sse | N/A | False (stdio) | Enables Standalone/SSE mode |
Sources: README.md:48-56, mbbank_mcp/main.py:23-31
Initialization Logic
The server follows a specific sequence to ensure valid credentials before opening network ports:
- Credential Retrieval: Reads from CLI flags or
os.getenv. - Client Instantiation: Creates
MBBankAsyncandFastMCPinstances. - Authentication: Executes
mbbank_client._authenticate(). - App Composition: Combines routes and middleware from
streamable_http_appandsse_appinto a singleStarletteinstance. - Server Launch: Starts
uvicornwith the aggregated application and lifespan context.
Sources: mbbank_mcp/main.py:32-68, mbbank_mcp/core.py:23-28
Execution Flow
The sequence of operations during a standalone session involves handling client connections via SSE and routing tool requests to the underlying MBBank library.
In Standalone Mode, the lifespan context manager is used to signal server startup and display access URLs to the console via stderr (using the eprint helper to avoid corrupting potential stdio pipes).
Sources: mbbank_mcp/main.py:12-17, mbbank_mcp/main.py:47-53, mbbank_mcp/core.py:108-112
Tool Availability in Standalone Mode
The Standalone Server exposes the same suite of tools as the standard mode, including account monitoring and transaction history.
| Tool Name | Purpose | Data Source |
|---|---|---|
get_balances | Retrieves current and international account balances. | mbbank_mcp/core.py:108-125 |
get_transactions | Fetches history for a specific account. | mbbank_mcp/core.py:141-168 |
start_transfer | Initiates a transfer and generates a QR code. | mbbank_mcp/core.py:30-84 |
get_cards | Lists associated debit and credit cards. | mbbank_mcp/core.py:170-191 |
get_savings | Provides data on OSA and SBA savings accounts. | mbbank_mcp/core.py:218-243 |
Sources: mbbank_mcp/core.py:30-243, mbbank_mcp/modals.py:7-78
Summary
Standalone Server Mode transforms the mbbank-mcp tool from a local utility into a network-accessible service. By utilizing SSE and Streamable HTTP via uvicorn and starlette, it provides a robust platform for remote bank monitoring and analytics while maintaining the security requirements of the MBBank API through pre-launch authentication.