Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pybatfish/mcp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

# Or run with a specific Batfish host:
BATFISH_HOST=my-batfish-host python -m pybatfish.mcp

# Or configure sessions in ~/.batfish/sessions.json:
# {"default": {"type": "bf", "params": {"host": "localhost"}}}
"""

from pybatfish.mcp.server import create_server
Expand Down
28 changes: 25 additions & 3 deletions pybatfish/mcp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,39 @@

batfish-mcp

Environment variables:
Session configuration:

* ``BATFISH_HOST`` — hostname of the Batfish server (default: ``localhost``).
Sessions can be configured in ``~/.batfish/sessions.json``::

{
"default": {"type": "bf", "params": {"host": "localhost"}},
"other": {"type": "bf", "params": {"host": "batfish2.example.com"}}
}

Precedence for the default session:

1. ``"default"`` entry in the sessions config file (if present)
2. ``BATFISH_HOST`` environment variable
3. ``localhost``
"""

import argparse
from pathlib import Path

from pybatfish.mcp.server import create_server


def main() -> None:
"""Start the Batfish MCP server using stdio transport."""
server = create_server()
parser = argparse.ArgumentParser(description="Batfish MCP server (Beta)")
parser.add_argument(
"--sessions-config",
type=Path,
default=None,
help="Path to sessions JSON config file (default: ~/.batfish/sessions.json)",
)
args = parser.parse_args()
server = create_server(sessions_config=args.sessions_config)
server.run(transport="stdio")


Expand Down
Loading