Examples & Use Cases
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
Complete Example: E-Commerce API
Next Steps
Last updated