π The fast, Pythonic way to build MCP servers and clients.
Update schema description wording for clarity
Jeremiah Lowin7114242e1eeb
diff --git a/src/fastmcp/prompts/prompt.py b/src/fastmcp/prompts/prompt.pyindex b88001662..b0c99e971 100644--- a/src/fastmcp/prompts/prompt.py+++ b/src/fastmcp/prompts/prompt.py@@ -198,7 +198,7 @@ class FunctionPrompt(Prompt):schema_str = json.dumps(param_schema, separators=(",", ":"))# Append schema info to description- schema_note = f"Arguments must be strings conforming to this JSON schema: {schema_str}"+ schema_note = f"Provide as a JSON string matching the following schema: {schema_str}"if arg_description:arg_description = f"{arg_description}\n\n{schema_note}"else:diff --git a/tests/prompts/test_prompt.py b/tests/prompts/test_prompt.pyindex 47d241ae9..e43313860 100644--- a/tests/prompts/test_prompt.py+++ b/tests/prompts/test_prompt.py@@ -388,34 +388,19 @@ class TestPromptArgumentDescriptions:# Check that non-string parameters have schema enhancementsnumbers_arg = next(arg for arg in prompt.arguments if arg.name == "numbers")- assert (- "Arguments must be strings conforming to this JSON schema:"- in numbers_arg.description- )+ assert "Provide as a JSON string matching the following schema:" in numbers_arg.descriptionassert '{"items":{"type":"integer"},"type":"array"}' in numbers_arg.descriptionmetadata_arg = next(arg for arg in prompt.arguments if arg.name == "metadata")- assert (- "Arguments must be strings conforming to this JSON schema:"- in metadata_arg.description- )- assert (- '{"additionalProperties":{"type":"string"},"type":"object"}'- in metadata_arg.description- )+ assert "Provide as a JSON string matching the following schema:" in metadata_arg.description+ assert '{"additionalProperties":{"type":"string"},"type":"object"}' in metadata_arg.descriptionthreshold_arg = next(arg for arg in prompt.arguments if arg.name == "threshold")- assert (- "Arguments must be strings conforming to this JSON schema:"- in threshold_arg.description- )+ assert "Provide as a JSON string matching the following schema:" in threshold_arg.descriptionassert '{"type":"number"}' in threshold_arg.descriptionactive_arg = next(arg for arg in prompt.arguments if arg.name == "active")- assert (- "Arguments must be strings conforming to this JSON schema:"- in active_arg.description- )+ assert "Provide as a JSON string matching the following schema:" in active_arg.descriptionassert '{"type":"boolean"}' in active_arg.descriptiondef test_enhanced_descriptions_with_existing_descriptions(self):@@ -439,10 +424,7 @@ class TestPromptArgumentDescriptions:assert numbers_arg.description is not Noneassert "A list of integers to process" in numbers_arg.descriptionassert "\n\n" in numbers_arg.description # Should have newline separator- assert (- "Arguments must be strings conforming to this JSON schema:"- in numbers_arg.description- )+ assert "Provide as a JSON string matching the following schema:" in numbers_arg.descriptiondef test_string_parameters_no_enhancement(self):"""Test that string parameters don't get schema enhancement."""@@ -455,7 +437,4 @@ class TestPromptArgumentDescriptions:for arg in prompt.arguments:# String parameters should not have schema enhancementif arg.description:- assert (- "Arguments must be strings conforming to this JSON schema:"- not in arg.description- )+ assert "Provide as a JSON string matching the following schema:" not in arg.descriptiondiff --git a/tests/server/test_server_interactions.py b/tests/server/test_server_interactions.pyindex 485621a7d..28797e521 100644--- a/tests/server/test_server_interactions.py+++ b/tests/server/test_server_interactions.py@@ -1812,29 +1812,15 @@ class TestPrompts:# Non-string parameters should have schema enhancementsnumbers_arg = args_by_name["numbers"]- assert (- "Arguments must be strings conforming to this JSON schema:"- in numbers_arg.description- )- assert (- '{"items":{"type":"integer"},"type":"array"}' in numbers_arg.description- )+ assert "Provide as a JSON string matching the following schema:" in numbers_arg.description+ assert '{"items":{"type":"integer"},"type":"array"}' in numbers_arg.descriptionmetadata_arg = args_by_name["metadata"]- assert (- "Arguments must be strings conforming to this JSON schema:"- in metadata_arg.description- )- assert (- '{"additionalProperties":{"type":"string"},"type":"object"}'- in metadata_arg.description- )+ assert "Provide as a JSON string matching the following schema:" in metadata_arg.description+ assert '{"additionalProperties":{"type":"string"},"type":"object"}' in metadata_arg.descriptionthreshold_arg = args_by_name["threshold"]- assert (- "Arguments must be strings conforming to this JSON schema:"- in threshold_arg.description- )+ assert "Provide as a JSON string matching the following schema:" in threshold_arg.descriptionassert '{"type":"number"}' in threshold_arg.descriptionasync def test_get_prompt(self):