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 operationId is missing.

Examples

slug = make_operation_slug(operation)
tool_name = make_tool_name(catalog_name="petstore", operation=operation)

Functions

make_catalog_slug(→ str)

Create a stable catalog slug.

make_operation_resource_uri(→ str)

Create a resource URI or URI template for one operation.

make_operation_slug(→ str)

Create a stable operation slug.

make_resource_uri(→ str)

Create a suggested MCP-style resource URI.

make_tag_slug(→ str)

Create a stable tag slug.

make_tool_name(→ str)

Create a suggested MCP tool name.

slugify(→ str)

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 operation or schema.

  • 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,
)
oas2mcp.utils.names.slugify(value: str) str[source][source]

Convert a string into a simple slug.

Parameters:

value – The input string.

Returns:

A lowercase slug.

Raises:

None.

Examples

assert slugify("Swagger Petstore - OpenAPI 3.0") == "swagger-petstore-openapi-3-0"