> For the complete documentation index, see [llms.txt](https://ai.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai.ortusbooks.com/model-context-protocol-mcp/server/getting-started.md).

# Getting Started

Get your first MCP server running in 5 minutes.

Get your first MCP server running in 5 minutes.

## What You'll Build

A simple MCP server that exposes two tools: search and calculate. Clients can invoke these tools via the Model Context Protocol.

## Step 1: Register Tools at Application Start

Create or edit your `Application.bx` to register tools when the application starts:

```javascript
// Application.bx
class {

    function onApplicationStart() {
        // Get or create an MCP server instance
        MCPServer( "myApp" )
            .setDescription( "My Application MCP Server" )
            .setVersion( "1.0.0" )

            // Register first tool
            .registerTool(
                aiTool( "search", "Search for documents", ( query ) => {
                    return searchService.search( query )
                } )
            )

            // Register second tool
            .registerTool(
                aiTool( "calculate", "Perform calculations", ( expression ) => {
                    return evaluate( expression )
                } )
            )
    }

    function onApplicationEnd() {
        // Clean up on shutdown
        bxModules.bxai.models.mcp.MCPServer::removeInstance( "myApp" )
    }

}
```

## Step 2: Access the MCP Endpoint

The module provides a built-in HTTP endpoint at `public/mcp.bxm`. Make a request specifying your server:

```bash
# Using query parameter
POST http://localhost/~bxai/mcp.bxm?server=myApp
Content-Type: application/json

{"jsonrpc":"2.0","method":"tools/list","id":"1"}
```

Or use URL segment:

```bash
# Using URL segment
POST http://localhost/~bxai/mcp.bxm/myApp
```

## Step 3: List Your Tools

```bash
curl -X POST http://localhost/~bxai/mcp.bxm?server=myApp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"tools/list","id":"1"}'
```

Response:

```json
{
    "jsonrpc": "2.0",
    "id": "1",
    "result": {
        "tools": [
            {
                "name": "search",
                "description": "Search for documents",
                "inputSchema": { ... }
            },
            {
                "name": "calculate",
                "description": "Perform calculations",
                "inputSchema": { ... }
            }
        ]
    }
}
```

## Step 4: Invoke a Tool

```bash
curl -X POST http://localhost/~bxai/mcp.bxm?server=myApp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "id": "2",
    "params": {
      "name": "search",
      "arguments": { "query": "BoxLang" }
    }
  }'
```

Response:

```json
{
    "jsonrpc": "2.0",
    "id": "2",
    "result": {
        "content": [
            { "type": "text", "text": "Search results for 'BoxLang'..." }
        ]
    }
}
```

## What's Next?

* 📖 [Transports](https://ai.ortusbooks.com/model-context-protocol-mcp/server/transports.md) — HTTP vs STDIO setup
* 🔐 [Server Configuration](https://ai.ortusbooks.com/model-context-protocol-mcp/server/server-configuration.md) — Add authentication
* 🧩 [Registering Tools](https://ai.ortusbooks.com/model-context-protocol-mcp/server/registration.md) — More complex tools
* 📋 [Observability](https://ai.ortusbooks.com/model-context-protocol-mcp/server/observability.md) — Monitor your server
* 🏗️ [Class-Based Servers](https://ai.ortusbooks.com/model-context-protocol-mcp/server/class-based-servers.md) — Organize complex servers
* 💡 [Examples](https://ai.ortusbooks.com/model-context-protocol-mcp/server/_examples.md) — Complete working code


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://ai.ortusbooks.com/model-context-protocol-mcp/server/getting-started.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
