Skip to content
Merged
37 changes: 37 additions & 0 deletions pybatfish/mcp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2018 The Batfish Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""MCP (Model Context Protocol) server for Batfish (Beta).

.. warning::
This MCP server is currently in **beta**. The tool names, parameters, and
return formats may change in future releases without prior notice.

This package provides an official MCP server that exposes Batfish network
analysis capabilities as MCP tools, enabling AI agents (such as Claude,
Cursor, and other MCP-compatible clients) to interact with Batfish for
network configuration analysis and verification.

Usage::

# Run the MCP server (stdio transport, for use with MCP clients):
python -m pybatfish.mcp

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

from pybatfish.mcp.server import create_server

__all__ = ["create_server"]
44 changes: 44 additions & 0 deletions pybatfish/mcp/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2018 The Batfish Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Entry point for running the Batfish MCP server (Beta).

.. warning::
This MCP server is currently in **beta**. The tool names, parameters, and
return formats may change in future releases without prior notice.

Run with::

python -m pybatfish.mcp

Or, after installing pybatfish with the ``mcp`` extra::

batfish-mcp

Environment variables:

* ``BATFISH_HOST`` — hostname of the Batfish server (default: ``localhost``).
"""

from pybatfish.mcp.server import create_server


def main() -> None:
"""Start the Batfish MCP server using stdio transport."""
server = create_server()
server.run(transport="stdio")


if __name__ == "__main__":
main()
Loading