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: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ RUN --mount=type=cache,target=/root/.cache/uv \
UV_LINK_MODE=copy uv sync --frozen --no-install-project || \
UV_LINK_MODE=copy uv sync --no-install-project

# Copy application source code and README (required by pyproject.toml)
# Copy application source code, assets, and README (required by pyproject.toml)
COPY src/ ./src/
COPY assets/ ./assets/
COPY README.md ./

# Install the project with optimizations
Expand Down
Binary file added assets/favicon.ico
Binary file not shown.
Binary file added assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo-flame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion src/lampyrid/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
from fastmcp.server.auth.auth import AuthProvider
from fastmcp.server.auth.providers.google import GoogleProvider
from fastmcp.utilities.logging import configure_logging
from fastmcp.utilities.types import Image
from mcp.types import Icon

from .clients.firefly import FireflyClient
from .config import settings
from .tools import register_all_tools
from .utils import get_assets_path, register_custom_routes


def _create_auth_provider() -> Optional[AuthProvider]:
Expand All @@ -32,11 +35,18 @@ def _create_auth_provider() -> Optional[AuthProvider]:

# Initialize FastMCP with optional authentication
auth_provider = _create_auth_provider()
mcp = FastMCP('lampyrid', auth=auth_provider)

# Load favicon icon
favicon_icon = Icon(src=Image(path=str(get_assets_path('favicon.png'))).to_data_uri())

mcp = FastMCP('lampyrid', auth=auth_provider, icons=[favicon_icon])
_client = FireflyClient()

# Configure logging
configure_logging(level='DEBUG')

# Register all MCP tools
register_all_tools(mcp, _client)

# Register custom HTTP routes
register_custom_routes(mcp)
42 changes: 42 additions & 0 deletions src/lampyrid/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
Custom HTTP routes and utilities for LamPyrid MCP server.

This module provides custom HTTP route handlers that are served at the root level,
alongside the MCP protocol endpoints.
"""

from pathlib import Path

from fastmcp import FastMCP
from starlette.requests import Request
from starlette.responses import FileResponse, JSONResponse


def get_project_root() -> Path:
return Path(__file__).parent.parent.parent


def get_assets_path(filename: str) -> Path:
return get_project_root() / 'assets' / filename


async def serve_favicon(request: Request):
"""Serve favicon.ico file at the root level."""
favicon_path = get_assets_path('favicon.ico')
if favicon_path.exists():
return FileResponse(favicon_path, media_type='image/x-icon')
return JSONResponse({'error': 'Not found'}, status_code=404)
Comment thread
RadCod3 marked this conversation as resolved.


def register_custom_routes(mcp: FastMCP) -> None:
"""
Register custom HTTP routes with the FastMCP server.

These routes are served at the root level (e.g., /favicon.ico),
not nested under the MCP protocol path (e.g., /mcp).

Args:
mcp: The FastMCP server instance
"""
# Register favicon route
mcp.custom_route('/favicon.ico', methods=['GET'])(serve_favicon)