Skip to main content
Glama
test_tool_prefix.py1.12 kB
""" Integration test for function name generation from OpenAPI spec. """ import os import json import pytest from mcp_openapi_proxy.server_fastmcp import list_functions @pytest.mark.integration def test_function_name_mapping(reset_env_and_module): """Test that function names are correctly generated from OpenAPI spec.""" env_key = reset_env_and_module spec_url = "https://petstore.swagger.io/v2/swagger.json" os.environ[env_key] = spec_url os.environ["DEBUG"] = "true" tools_json = list_functions(env_key=env_key) tools = json.loads(tools_json) assert isinstance(tools, list), "Functions should be a list" assert len(tools) > 0, "No functions generated from spec" for tool in tools: name = tool["name"] # Only check HTTP method prefix for tools with a method (skip built-ins like list_resources) if tool.get("method"): assert name.startswith(("get_", "post_", "put_", "delete_")), \ f"Function name {name} should start with HTTP method prefix" assert " " not in name, f"Function name {name} should have no spaces"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/matthewhand/mcp-openapi-proxy'

If you have feedback or need assistance with the MCP directory API, please join our Discord server