Custom Tools

Guide to creating custom MCP tools for your specific use cases.

Why Create Custom Tools?

While AIDP provides standard tools for common use cases, you may want to create custom tools for:

  • Domain-Specific Logic: Business logic unique to your application

  • Data Transformation: Custom formatting or filtering of AIDP data

  • Integration: Combining AIDP data with other data sources

  • Specialized Queries: Pre-configured searches for specific scenarios


Tool Structure

Every MCP tool has three components:

  1. Metadata: Name, description, and parameters

  2. Handler: Function that executes the tool

  3. Validation: Parameter validation logic

Basic Tool Template

import { Tool, ToolHandler } from '@aidp/mcp-server';

export const myCustomTool: Tool = {
  name: 'my_custom_tool',
  description: 'Description of what this tool does',
  parameters: {
    type: 'object',
    properties: {
      param1: {
        type: 'string',
        description: 'Description of param1',
        required: true,
      },
      param2: {
        type: 'number',
        description: 'Description of param2',
        required: false,
        default: 10,
      },
    },
  },
  handler: async (params) => {
    // Tool implementation
    return {
      success: true,
      data: {
        /* result */
      },
    };
  },
};

Example 1: Nearby Restaurants Tool

A specialized tool for finding restaurants near a location.

Usage


Example 2: Business Comparison Tool

Compare multiple businesses side-by-side.


Example 3: Smart Recommendations Tool

AI-powered recommendations based on user preferences.


Registering Custom Tools

In Configuration File

Add to mcp-config.yml:

Programmatically


Best Practices

1. Clear Naming

Use descriptive, action-oriented names:

Good: find_nearby_restaurants, compare_businessesBad: tool1, search, get_data

2. Comprehensive Descriptions

Provide detailed descriptions:

3. Validate Parameters

Always validate input parameters:

4. Handle Errors Gracefully

Provide helpful error messages:

5. Cache Expensive Operations

Cache results to improve performance:


Testing Custom Tools

See Testing Guide for comprehensive testing strategies.

Quick Test


Next Steps


Support

Last updated