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

# Custom MCP

> Connect to your own MCP server for full control and custom implementations.

Custom MCP Connectors connect to your own MCP servers. Ideal for proprietary tools, complex logic, or internal systems.

## When to Use Custom MCP

Use Custom MCP when:

* Building proprietary tools
* Integrating internal systems
* Need full control over implementation
* REST doesn't fit use case
* Want to leverage MCP ecosystem

## Custom MCP vs Alternatives

| Option             | Control | Setup  | Maintenance |
| ------------------ | ------- | ------ | ----------- |
| **REST Connector** | Medium  | Easy   | Low         |
| **MCP Registry**   | None    | Easy   | None        |
| **Custom MCP**     | Full    | Hard   | Medium      |
| **Plugin**         | Full    | Medium | Medium      |

## Creating Custom MCP Connector

<Steps>
  <Step title="Have MCP Server Ready">
    Your MCP server should be:

    * Running and accessible
    * On stable URL or local network
    * Properly authenticated
    * Implements MCP spec
  </Step>

  <Step title="Start Creation">
    1. **Connectors** > **Create Connector**
    2. Choose **Custom MCP**
  </Step>

  <Step title="Configure Transport">
    Choose how to connect:

    * **HTTP** - Standard web connection
    * **SSE** - Server-Sent Events
    * **Stdio** - Direct process connection

    Provide URL or connection details.
  </Step>

  <Step title="Set Environment">
    1. Add environment variables if needed
    2. Configure authentication
    3. Test connection
  </Step>

  <Step title="Test Tools">
    1. Connector auto-discovers tools
    2. Test each tool
    3. Verify responses
  </Step>

  <Step title="Save">
    Connector now ready to attach to agents/gateways.
  </Step>
</Steps>

## MCP Server Setup

Your MCP server needs to:

1. **Implement MCP Protocol** - Follow Model Context Protocol spec
2. **Expose Tools** - Define available functions
3. **Handle Requests** - Process incoming calls
4. **Return Results** - Provide structured responses
5. **Be Accessible** - Network accessible to Noorle

### Minimal MCP Server (Node.js)

```javascript theme={null}
const { Server } = require("@modelcontextprotocol/sdk");

const server = new Server({
  name: "my-mcp",
  version: "1.0.0"
});

server.setRequestHandler("tools/list", async () => {
  return {
    tools: [
      {
        name: "greet",
        description: "Greet someone",
        inputSchema: {
          type: "object",
          properties: {
            name: { type: "string" }
          }
        }
      }
    ]
  };
});

server.setRequestHandler("tools/call", async (request) => {
  if (request.params.name === "greet") {
    return {
      content: [{
        type: "text",
        text: `Hello, ${request.params.arguments.name}!`
      }]
    };
  }
});

server.start();
```

### Minimal MCP Server (Python)

```python theme={null}
from mcp.server import Server

app = Server("my-mcp", "1.0.0")

@app.list_tools()
async def list_tools():
    return [
        {
            "name": "greet",
            "description": "Greet someone",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "name": {"type": "string"}
                }
            }
        }
    ]

@app.call_tool()
async def call_tool(name: str, arguments: dict):
    if name == "greet":
        return {
            "content": [{
                "type": "text",
                "text": f"Hello, {arguments['name']}!"
            }]
        }

if __name__ == "__main__":
    app.run()
```

## Transport Options

### HTTP

```
URL: https://your-mcp-server.com
Supports: All operations
Auth: Yes (headers, OAuth)
```

### SSE (Server-Sent Events)

```
URL: https://your-mcp-server.com/sse
Supports: Streaming responses
Auth: Yes
```

### Stdio

```
Command: /path/to/mcp-server
Supports: Direct process
Auth: Via environment vars
```

## Authentication

Secure your MCP server:

**API Key:**

```json theme={null}
{
  "auth_config": {
    "type": "bearer",
    "token": "your-api-key"
  }
}
```

**OAuth 2.0:**

```json theme={null}
{
  "auth_config": {
    "type": "oauth2",
    "authorization_url": "...",
    "token_url": "...",
    "client_id": "...",
    "client_secret": "..."
  }
}
```

**Custom Headers:**

```json theme={null}
{
  "headers": [
    ["Authorization", "Bearer token"],
    ["X-Custom-Header", "value"]
  ]
}
```

## Tool Discovery

Noorle automatically discovers tools from your MCP server:

1. Connector initializes connection
2. Requests `tools/list`
3. Server returns tool definitions
4. Tools immediately available

No manual tool definition needed.

## Testing Tools

After creating connector:

1. Click **Test**
2. Select tool from list
3. Enter sample input
4. Execute
5. View response

Verify all tools work as expected.

## Environment Variables

Store sensitive config in environment variables:

```json theme={null}
{
  "env": {
    "API_KEY": "encrypted_value",
    "DATABASE_URL": "encrypted_value"
  }
}
```

In your MCP server, access via:

```javascript theme={null}
process.env.API_KEY
```

## Cost

For current pricing details, see [Pricing](https://noorle.com/pricing/).

Monitor in **Account** > **Usage** dashboard.

## Best Practices

### Tool Design

* Clear, descriptive names
* Complete descriptions
* Comprehensive input schemas
* Useful response formats

### Error Handling

Return meaningful errors:

```json theme={null}
{
  "isError": true,
  "content": [{
    "type": "text",
    "text": "Error: Invalid input"
  }]
}
```

### Performance

* Optimize tool execution
* Handle timeouts gracefully
* Return efficient responses
* Consider caching

### Security

* Authenticate all requests
* Validate inputs rigorously
* Don't expose secrets
* Log activity

## Troubleshooting

### "Connection Failed"

* Verify server is running
* Check URL is accessible
* Ensure firewall allows connection
* Test with `curl` or `mcp-cli`

### "Tool Not Found"

* Verify tool registered in `tools/list`
* Check tool name exactly
* Restart MCP server
* Re-create connector

### "Authentication Failed"

* Verify credentials are correct
* Check auth method matches
* Ensure token hasn't expired
* Review server auth config

### "Timeout"

* Server response too slow
* Increase timeout setting
* Optimize server performance
* Check network latency

## Hosting Options

Run your MCP server on any cloud platform or serverless provider that supports your runtime. Deploy to any service with:

* Full control over infrastructure
* Support for your language/framework
* Network accessibility to Noorle
* Proper monitoring and logging

## Monitoring

Monitor custom MCP health:

1. **Connectors** > Select connector
2. View **Activity** tab
3. Check recent calls
4. View errors and latency

## Next Steps

* [REST Connectors](/docs/run/connectors/rest-connectors)
* [MCP Registry](/docs/run/connectors/mcp-registry)
* [Authentication](/docs/run/connectors/authentication)
* [MCP Specification](https://spec.modelcontextprotocol.io/)
