Overview
Extend MagOneAI with custom tools for your internal systems, proprietary APIs, and unique business logic. Any service with an API can become an MCP tool that your agents can use. Custom tools enable agents to interact with:- Internal APIs — your company’s microservices and internal tools
- Proprietary systems — ERP, CRM, inventory management, etc.
- Third-party services — APIs not natively integrated with MagOneAI
- Legacy systems — wrap older SOAP or REST APIs with MCP interface
- Custom business logic — implement domain-specific operations as tools
How to add custom MCP tools
Follow this workflow to add custom tools to your MagOneAI projects.Build or deploy an MCP server
Create an MCP server that wraps your API. You can:
- Build from scratch using MCP SDKs (Python or TypeScript)
- Use an existing MCP server from the community
- Deploy pre-built MCP servers for common services
Define tool schemas
Each tool needs:
- Name: Unique identifier (e.g.,
get_customer_details) - Description: What the tool does (used by agents to decide when to use it)
- Parameters: JSON Schema defining inputs
- Return type: Schema for response structure
Register the MCP server in MagOneAI
In Project Settings → Integrations → Custom Tools, add your MCP server:
- Server URL (e.g.,
http://mcp-server:8000) - Connection protocol (HTTP, WebSocket, or stdio)
- Authentication details (if required)
Configure authentication
Provide credentials the MCP server needs to access your API:
- API keys
- OAuth tokens
- Basic auth credentials
- Custom headers
Test the tool connection
Use the built-in tool tester to verify:
- MCP server is reachable
- Tool definitions are valid
- Test calls execute successfully
- Authentication works correctly
MCP server development basics
MCP servers are lightweight processes that expose tools to AI agents. They implement the Model Context Protocol specification.Architecture
The MCP server acts as an adapter between the standardized MCP protocol and your specific API or system.Available SDKs
Build MCP servers using official SDKs:Python SDK
TypeScript SDK
Basic MCP server structure (Python)
Here’s a minimal MCP server that wraps a REST API:Basic MCP server structure (TypeScript)
The same server in TypeScript:Tool definition best practices
Write clear, descriptive tool names
Write clear, descriptive tool names
Tool names should be descriptive and follow a consistent naming convention.✅ Good:
search_customers, create_support_ticket, get_inventory_status❌ Bad: search, create, get_dataAgents use tool names to understand what the tool does. Clear names improve agent decision-making.Provide detailed descriptions
Provide detailed descriptions
Descriptions help agents decide when to use a tool. Include:
- What the tool does
- What data it returns
- When it should be used
Use JSON Schema for parameter validation
Use JSON Schema for parameter validation
Define precise parameter schemas:
- Required vs optional parameters
- Data types (string, integer, boolean, array, object)
- Constraints (min/max values, string patterns, enums)
- Default values
Return structured data
Return structured data
Always return structured JSON responses, not plain text. This allows agents to:❌ Bad:
- Extract specific fields
- Pass data to subsequent tools
- Format information appropriately
Handle errors gracefully
Handle errors gracefully
Return structured error responses that agents can interpret:This allows agents to handle errors intelligently (e.g., “I couldn’t find that customer” instead of crashing).
Example: Custom CRM integration
Let’s build a complete MCP server for a fictional CRM system.Tools to implement
Our CRM integration will expose these tools:- search_contacts — find contacts by name, email, or company
- get_deal_status — retrieve status of a sales opportunity
- update_opportunity — modify deal amount, stage, or close date
- log_activity — record a call, email, or meeting with a contact
Complete Python implementation
Deploying the MCP server
Package and deploy your MCP server:http://your-server:8000.
Authentication for custom integrations
Your MCP server needs credentials to access your APIs. MagOneAI provides secure credential management.API key authentication
For services using API keys:- Store the API key in MagOneAI’s Vault (Admin Portal → Secrets → Add Secret)
- Reference the secret when configuring the MCP server:
vault:crm/api_key - MagOneAI injects the key into the MCP server environment at runtime
OAuth2 for custom services
For OAuth2-protected APIs, MagOneAI can manage the OAuth flow:Configure OAuth app
Register an OAuth application with your service provider. Note the client ID and client secret.
Add OAuth config to MagOneAI
In Admin Portal, add OAuth configuration:
- Client ID
- Client secret
- Authorization URL
- Token URL
- Required scopes
Users authorize access
When users first use your tool, they complete the OAuth flow. MagOneAI stores their access and refresh tokens in Vault.
Custom authentication schemes
For custom authentication (HMAC signatures, JWT, etc.), implement authentication in your MCP server and store necessary secrets in Vault.Testing custom tools
Before deploying to production, thoroughly test your custom tools.Local testing
Test your MCP server locally using the MCP Inspector:- View tool definitions
- Execute tools with test parameters
- Inspect request/response payloads
- Debug connection issues
Integration testing in MagOneAI
Once registered in MagOneAI, use the built-in tool tester:- Go to Project Settings → Integrations → Custom Tools → Your Tool
- Click Test Tool
- Select a tool to test
- Enter test parameters
- Execute and verify the response
Testing in workflows
Create a test workflow that uses your custom tools:- Build a simple workflow with an Agent node
- Attach your custom tools to the agent
- Provide test prompts that should trigger tool usage
- Verify the agent calls tools correctly and handles responses