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

Annotation-Based Discovery

Automatically discover and register tools, resources, and prompts from annotated methods.

Overview

Instead of manually calling .registerTool() for each method, use annotations to mark methods as MCP capabilities. Then use scan() or scanClass() to auto-register them.

Two Discovery Methods

Method
Purpose
Use Case

scan( path, recurse )

Scan a package/directory for annotated .bx files

Large apps with organized folder structure

scanClass( classPath )

Scan a single class

Quick discovery or specific classes

scan() — Packages & Directories

Automatically discover all annotated methods in a package or folder (supports recursion).

// Dot-notation package path
MCPServer( "myApp" ).scan( "models.tools" )

// Dot-notation with recursion disabled
MCPServer( "myApp" ).scan( "models.tools", false )

// Absolute directory path
MCPServer( "myApp" ).scan( "/path/to/tools/" )

// Relative directory path
MCPServer( "myApp" ).scan( "./tools" )

scanClass() — Single Classes

Target one specific class (existing instance, dot-path, or file path).

Mixing scan() and scanClass()

Both methods are chainable:

@mcpTool Annotation

Register methods as MCP tools:

Annotation Formats:

  • @mcpTool — Name from method name, description from function hint

  • @mcpTool( "Description" ) — Custom description

  • @mcpTool( { name: "...", description: "...", version: "..." } ) — All custom

@mcpResource Annotation

Register methods as MCP resources:

Annotation Formats:

  • @mcpResource — URI and name from method name

  • @mcpResource( "Description" ) — Custom description

  • @mcpResource( { uri: "...", name: "...", description: "...", mimeType: "..." } ) — All custom

@mcpPrompt Annotation

Register methods as MCP prompts:

Annotation Formats:

  • @mcpPrompt — Name from method name

  • @mcpPrompt( "Description" ) — Custom description

  • @mcpPrompt( { name: "...", description: "...", arguments: [...] } ) — All custom

Complete Example

Project Structure

SearchTools.bx

AdminTools.bx

Application.bx

After scan(), all methods annotated with @mcpTool, @mcpResource, or @mcpPrompt are automatically registered!

Benefits of Annotation-Based Discovery

Cleaner Code — Keep tool definitions next to implementations ✅ Less Boilerplate — No repetitive .registerTool() calls ✅ Scalability — Add new tools without updating registration code ✅ Organization — Group related tools in classes ✅ Documentation — Hints and documentation preserved in code

Next Steps

Last updated