} */ function build_ai_catalog(): array { $host = (string) wp_parse_url( home_url( '/' ), PHP_URL_HOST ); $urn = static function ( string $kind, string $name ) use ( $host ): string { return 'urn:air:' . $host . ':' . $kind . ':' . $name; }; $entries = array(); $mcp = detect_mcp_server(); if ( $mcp ) { $entries[] = array( 'identifier' => $urn( 'mcp', 'server' ), 'name' => $mcp['name'] . ' (Streamable HTTP)', 'type' => 'application/json', 'protocol' => 'mcp', 'url' => $mcp['endpoint'], ); } if ( is_feature_enabled( 'mcp_server_card' ) ) { $entries[] = array( 'identifier' => $urn( 'mcp', 'server-card' ), 'name' => 'MCP Server Card', 'type' => 'application/mcp-server-card+json', 'url' => home_url( '/.well-known/mcp/server-card.json' ), ); } if ( is_feature_enabled( 'agent_skills_index' ) ) { $entries[] = array( 'identifier' => $urn( 'skills', 'index' ), 'name' => 'Agent Skills Index', 'type' => 'application/json', 'url' => home_url( '/.well-known/agent-skills/index.json' ), ); } if ( is_feature_enabled( 'api_catalog' ) ) { $entries[] = array( 'identifier' => $urn( 'api', 'catalog' ), 'name' => 'API Catalog (RFC 9727)', 'type' => 'application/linkset+json', 'url' => home_url( '/.well-known/api-catalog' ), ); } if ( is_feature_enabled( 'openapi' ) ) { $entries[] = array( 'identifier' => $urn( 'api', 'openapi' ), 'name' => 'OpenAPI document', 'type' => 'application/vnd.oai.openapi+json', 'url' => home_url( '/openapi.json' ), ); } if ( is_feature_enabled( 'llms_txt' ) ) { $entries[] = array( 'identifier' => $urn( 'content', 'llms-txt' ), 'name' => 'llms.txt', 'type' => 'text/markdown', 'url' => home_url( '/llms.txt' ), ); } if ( is_feature_enabled( 'auth_md' ) ) { $entries[] = array( 'identifier' => $urn( 'auth', 'auth-md' ), 'name' => 'auth.md', 'type' => 'text/markdown', 'url' => home_url( '/auth.md' ), ); } $catalog = array( 'specVersion' => '1.0', 'host' => array( 'name' => markdown_safe_text( get_bloginfo( 'name' ) ), 'url' => home_url( '/' ), ), 'entries' => $entries, ); /** * Filter the AI Catalog document before it's serialized. * * @param array $catalog Catalog with `specVersion`, `host`, `entries`. */ $filtered = apply_filters( 'ajaco_ai_catalog', $catalog ); return is_array( $filtered ) ? $filtered : $catalog; }