oas2mcp.utils.names¶
Naming helpers for normalized catalogs and MCP preparation.
- Purpose:
Create stable slugs, tool names, and resource URIs from normalized OpenAPI metadata.
- Design:
Keep naming deterministic.
Prefer operation identifiers when available.
Fall back to method + path when
operationIdis missing.
Examples
slug = make_operation_slug(operation)
tool_name = make_tool_name(catalog_name="petstore", operation=operation)
Functions¶
|
Create a stable catalog slug. |
|
Create a resource URI or URI template for one operation. |
|
Create a stable operation slug. |
|
Create a suggested MCP-style resource URI. |
|
Create a stable tag slug. |
|
Create a suggested MCP tool name. |
|
Convert a string into a simple slug. |
Module Contents¶
- oas2mcp.utils.names.make_catalog_slug(catalog_name: str) str[source][source]¶
Create a stable catalog slug.
- Parameters:
catalog_name – The catalog display name.
- Returns:
The catalog slug.
- Raises:
None. –
Examples
slug = make_catalog_slug("Swagger Petstore - OpenAPI 3.0")
- oas2mcp.utils.names.make_operation_resource_uri(*, catalog_name: str, operation: oas2mcp.models.normalized.ApiOperation) str[source][source]¶
Create a resource URI or URI template for one operation.
- Parameters:
catalog_name – The API catalog name.
operation – The normalized API operation.
- Returns:
A stable URI for read-only resources or a URI template for parameterized read operations.
- oas2mcp.utils.names.make_operation_slug(operation: oas2mcp.models.normalized.ApiOperation) str[source][source]¶
Create a stable operation slug.
- Parameters:
operation – The normalized API operation.
- Returns:
The operation slug.
- Raises:
None. –
Examples
slug = make_operation_slug(operation)
- oas2mcp.utils.names.make_resource_uri(*, catalog_name: str, resource_kind: str, identifier: str) str[source][source]¶
Create a suggested MCP-style resource URI.
- Parameters:
catalog_name – The API catalog name.
resource_kind – The logical resource kind, such as
operationorschema.identifier – The resource identifier or slug.
- Returns:
A suggested resource URI.
- Raises:
None. –
Examples
uri = make_resource_uri( catalog_name="Petstore", resource_kind="operation", identifier="get-pet-by-id", )
- oas2mcp.utils.names.make_tag_slug(tag_name: str) str[source][source]¶
Create a stable tag slug.
- Parameters:
tag_name – The tag name.
- Returns:
The tag slug.
- Raises:
None. –
Examples
slug = make_tag_slug("pet")
- oas2mcp.utils.names.make_tool_name(*, catalog_name: str, operation: oas2mcp.models.normalized.ApiOperation) str[source][source]¶
Create a suggested MCP tool name.
- Parameters:
catalog_name – The API catalog name.
operation – The normalized API operation.
- Returns:
A suggested tool name.
- Raises:
None. –
Examples
tool_name = make_tool_name( catalog_name="Petstore", operation=operation, )