> ## Documentation Index
> Fetch the complete documentation index at: https://docs.leanmcp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Build MCP Server

> Create a new MCP server from templates and configuration

Build a new MCP server with your tools, resources, and prompts.

## Request

<ParamField body="name" type="string" required>
  Name of your MCP server
</ParamField>

<ParamField body="template" type="string" required>
  Template to use. Options: `basic`, `advanced`, `custom`
</ParamField>

<ParamField body="tools" type="array">
  Array of tools your MCP provides

  <Expandable title="Tool Object">
    <ParamField body="name" type="string" required>
      Tool identifier (e.g., "send\_email")
    </ParamField>

    <ParamField body="description" type="string" required>
      What this tool does (helps AI understand when to use it)
    </ParamField>

    <ParamField body="inputSchema" type="object" required>
      JSON Schema for tool inputs
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="resources" type="array">
  Array of resources your MCP provides

  <Expandable title="Resource Object">
    <ParamField body="uri" type="string" required>
      Resource URI (e.g., "user://profile")
    </ParamField>

    <ParamField body="name" type="string" required>
      Human-readable name
    </ParamField>

    <ParamField body="description" type="string" required>
      What data this resource provides
    </ParamField>

    <ParamField body="mimeType" type="string">
      Content type (default: "application/json")
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="prompts" type="array">
  Array of prompt templates your MCP provides

  <Expandable title="Prompt Object">
    <ParamField body="name" type="string" required>
      Prompt identifier
    </ParamField>

    <ParamField body="description" type="string" required>
      What this prompt helps with
    </ParamField>

    <ParamField body="template" type="string" required>
      Prompt template with variables
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Whether the build succeeded
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="Build Data">
    <ResponseField name="mcp_id" type="string">
      Unique ID for your MCP server
    </ResponseField>

    <ResponseField name="name" type="string">
      Name of your MCP server
    </ResponseField>

    <ResponseField name="status" type="string">
      Build status: "building", "ready", "failed"
    </ResponseField>

    <ResponseField name="url" type="string">
      URL where your MCP is accessible
    </ResponseField>

    <ResponseField name="build_time" type="number">
      Build time in seconds
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash Example Request theme={null}
  curl -X POST https://api.leanmcp.com/v1/build \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "email-assistant",
      "template": "basic",
      "tools": [
        {
          "name": "send_email",
          "description": "Send an email to someone",
          "inputSchema": {
            "type": "object", 
            "properties": {
              "to": {"type": "string"},
              "subject": {"type": "string"},
              "body": {"type": "string"}
            },
            "required": ["to", "subject", "body"]
          }
        }
      ],
      "resources": [
        {
          "uri": "user://contacts",
          "name": "User Contacts",
          "description": "List of user contact information",
          "mimeType": "application/json"
        }
      ]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "success": true,
    "data": {
      "mcp_id": "mcp_abc123def456",
      "name": "email-assistant", 
      "status": "ready",
      "url": "https://mcp-abc123def456.leanmcp.com",
      "build_time": 8.5
    },
    "meta": {
      "request_id": "req_789xyz",
      "timestamp": "2023-12-01T12:00:00Z"
    }
  }
  ```
</ResponseExample>

## Common Use Cases

### Simple Tool MCP

Build an MCP with just tools (no resources or prompts):

```json theme={null}
{
  "name": "calculator",
  "template": "basic",
  "tools": [
    {
      "name": "add",
      "description": "Add two numbers together",
      "inputSchema": {
        "type": "object",
        "properties": {
          "a": {"type": "number"},
          "b": {"type": "number"}
        }
      }
    }
  ]
}
```

### Data Access MCP

Build an MCP that gives AI access to your data:

```json theme={null}
{
  "name": "user-data",
  "template": "basic", 
  "resources": [
    {
      "uri": "user://profile",
      "name": "User Profile",
      "description": "Current user profile information"
    },
    {
      "uri": "user://settings", 
      "name": "User Settings",
      "description": "User application settings"
    }
  ]
}
```
