mirror of
https://github.com/dnlbauer/cordra-mcp.git
synced 2026-09-10 21:55:30 +00:00
Merge pull request #2 from jgrieb/main
feat: added configuration to run Docker in http mode
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
FROM python:3.13-alpine
|
FROM python:3.13-alpine
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
# Install package manager
|
# Install package manager
|
||||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||||
|
|
||||||
@@ -18,4 +20,6 @@ COPY src src
|
|||||||
RUN uv sync \
|
RUN uv sync \
|
||||||
--locked
|
--locked
|
||||||
|
|
||||||
|
ENV CORDRA_RUN_MODE=http
|
||||||
|
|
||||||
CMD ["uv", "run", "cordra-mcp"]
|
CMD ["uv", "run", "cordra-mcp"]
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
"""Configuration settings for the MCP Cordra server."""
|
"""Configuration settings for the MCP Cordra server."""
|
||||||
|
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
from pydantic import Field, field_validator
|
from pydantic import Field, field_validator
|
||||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
@@ -16,6 +18,10 @@ class CordraConfig(BaseSettings):
|
|||||||
default="https://localhost:8443",
|
default="https://localhost:8443",
|
||||||
description="Base URL of the Cordra repository",
|
description="Base URL of the Cordra repository",
|
||||||
)
|
)
|
||||||
|
host: str = Field(
|
||||||
|
default="0.0.0.0",
|
||||||
|
description="The host under which the MCP server runs when deployed as http run_mode",
|
||||||
|
)
|
||||||
username: str | None = Field(
|
username: str | None = Field(
|
||||||
default=None, description="Username for Cordra authentication"
|
default=None, description="Username for Cordra authentication"
|
||||||
)
|
)
|
||||||
@@ -26,6 +32,9 @@ class CordraConfig(BaseSettings):
|
|||||||
default=True, description="Whether to verify SSL certificates"
|
default=True, description="Whether to verify SSL certificates"
|
||||||
)
|
)
|
||||||
timeout: int = Field(default=30, description="Request timeout in seconds")
|
timeout: int = Field(default=30, description="Request timeout in seconds")
|
||||||
|
run_mode: Literal["stdio", "http"] | None = Field(
|
||||||
|
default="stdio", description="Run mode for the MCP client"
|
||||||
|
)
|
||||||
log_level: str = Field(
|
log_level: str = Field(
|
||||||
default="INFO",
|
default="INFO",
|
||||||
description="Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
|
description="Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ from .client import (
|
|||||||
from .config import CordraConfig
|
from .config import CordraConfig
|
||||||
|
|
||||||
# Initialize the MCP server
|
# Initialize the MCP server
|
||||||
mcp = FastMCP("cordra-mcp")
|
config = CordraConfig()
|
||||||
|
mcp = FastMCP("cordra-mcp", host=config.host, port=8000)
|
||||||
|
|
||||||
# Initialize Cordra client at startup
|
# Initialize Cordra client at startup
|
||||||
config = CordraConfig()
|
|
||||||
cordra_client = CordraClient(config)
|
cordra_client = CordraClient(config)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -311,8 +311,11 @@ async def initialize_server() -> None:
|
|||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
"""Main entry point for the MCP server."""
|
"""Main entry point for the MCP server."""
|
||||||
asyncio.run(initialize_server())
|
if config.run_mode == "stdio":
|
||||||
mcp.run()
|
asyncio.run(initialize_server())
|
||||||
|
mcp.run()
|
||||||
|
else:
|
||||||
|
mcp.run(transport="streamable-http")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user