Skip to main content

Module bazaar

Module bazaar 

Source
Expand description

The bazaar extension for resource discovery and cataloging. The bazaar extension for resource discovery and cataloging.

The bazaar extension enables resource servers to declare their endpoint specifications (HTTP method or MCP tool name, input parameters, and output format) so that facilitators can catalog and index them in a discovery service.

§Example: GET Endpoint

use x402_extensions::bazaar::*;
use x402_core::types::Extension;
use serde_json::json;

let info = BazaarInfo::builder()
    .input(BazaarInput::Http(BazaarHttpInput::builder()
        .method(HttpMethod::GET)
        .query_params(json!({"city": "San Francisco"}))
        .build()))
    .output(BazaarOutput::builder()
        .output_type("json")
        .example(json!({"city": "San Francisco", "weather": "foggy"}))
        .build())
    .build();

let ext = Extension::typed(info);
let (key, transport) = ext.into_pair();
assert_eq!(key, "bazaar");

§Example: POST Endpoint

use x402_extensions::bazaar::*;
use x402_core::types::Extension;
use serde_json::json;

let info = BazaarInfo::builder()
    .input(BazaarInput::Http(BazaarHttpInput::builder()
        .method(HttpMethod::POST)
        .body_type("json")
        .body(json!({"query": "example"}))
        .build()))
    .build();

let ext = Extension::typed(info);
let (key, _) = ext.into_pair();
assert_eq!(key, "bazaar");

§Example: MCP Tool

use x402_extensions::bazaar::*;
use x402_core::types::Extension;
use serde_json::json;

let info = BazaarInfo::builder()
    .input(BazaarInput::Mcp(BazaarMcpInput::builder()
        .tool("financial_analysis")
        .input_schema(json!({
            "type": "object",
            "properties": {
                "ticker": { "type": "string" }
            },
            "required": ["ticker"]
        }))
        .description("AI-powered financial analysis")
        .build()))
    .output(BazaarOutput::builder()
        .output_type("json")
        .example(json!({"summary": "Strong fundamentals", "score": 8.5}))
        .build())
    .build();

let ext = Extension::typed(info);
let (key, _) = ext.into_pair();
assert_eq!(key, "bazaar");

Structs§

BazaarHttpInput
HTTP endpoint input specification.
BazaarHttpInputBuilder
Use builder syntax to set the inputs and finish with build().
BazaarInfo
Discovery info for the bazaar extension.
BazaarInfoBuilder
Use builder syntax to set the inputs and finish with build().
BazaarMcpInput
MCP tool input specification.
BazaarMcpInputBuilder
Use builder syntax to set the inputs and finish with build().
BazaarOutput
Output specification for a bazaar discovery entry.
BazaarOutputBuilder
Use builder syntax to set the inputs and finish with build().

Enums§

BazaarInput
Discriminated union for input types.
HttpMethod
HTTP methods supported by the bazaar extension.
McpTransport
MCP transport protocol options.