38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""Keep ARTEMIS tool descriptions stable across supported Python versions."""
|
|
|
|
from textwrap import dedent
|
|
|
|
from mcp.server.fastmcp import FastMCP
|
|
|
|
|
|
class ArtemisFastMCP(FastMCP):
|
|
"""Normalize docstring indentation before FastMCP publishes tool metadata."""
|
|
|
|
def add_tool(
|
|
self,
|
|
fn,
|
|
name=None,
|
|
title=None,
|
|
description=None,
|
|
annotations=None,
|
|
icons=None,
|
|
meta=None,
|
|
structured_output=None,
|
|
):
|
|
if not description:
|
|
# Python 3.13+ removes this indentation at compilation; 3.12 leaves
|
|
# it in __doc__. Retain blank lines, including the final newline,
|
|
# so the existing catalog and pinned schemas stay byte-for-byte equal.
|
|
first, separator, body = (fn.__doc__ or "").expandtabs().partition("\n")
|
|
description = first.lstrip() + separator + dedent(body)
|
|
super().add_tool(
|
|
fn,
|
|
name=name,
|
|
title=title,
|
|
description=description,
|
|
annotations=annotations,
|
|
icons=icons,
|
|
meta=meta,
|
|
structured_output=structured_output,
|
|
)
|