For the complete documentation index, see llms.txt. This page is also available as Markdown.

Examples & Use Cases

Complete working examples for common MCP server scenarios.

Complete Application Setup

// Application.bx
class {

    function onApplicationStart() {
        // Create public server
        MCPServer( "public" )
            .setDescription( "Public API Server" )
            .setVersion( "1.0.0" )
            .withCors( "*" )
            .registerTool(
                aiTool( "searchProducts", "Search product catalog", ( query ) => {
                    return productService.search( query )
                } )
            )
            .registerTool(
                aiTool( "getProduct", "Get product details", ( productId ) => {
                    return productService.getById( productId )
                } )
            )

        // Create admin server (authenticated)
        MCPServer( "admin" )
            .setDescription( "Admin Tools" )
            .setVersion( "1.0.0" )
            .withBasicAuth( getEnv( "ADMIN_USER" ), getEnv( "ADMIN_PASS" ) )
            .registerTool(
                aiTool( "createProduct", "Create new product", ( name, price ) => {
                    return productService.create( name, price )
                } )
            )
            .registerTool(
                aiTool( "deleteProduct", "Delete product", ( productId ) => {
                    return productService.delete( productId )
                } )
            )

        return true
    }

    function onApplicationEnd() {
        bxModules.bxai.models.mcp.MCPServer::clearAllInstances()
    }

}

Class-Based Server Example

Multi-Server Setup with Monitoring

Using MCP Client to Connect

Custom HTTP Endpoint

STDIO Transport Entry Point

Run: boxlang mcp-stdio.bxs --server stdio-server

Complete Example: E-Commerce API

Next Steps

Last updated