Labsco
DealExpress logo

DealX

from DealExpress

MCP Server for DealX platform

๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredAdvanced setup

@dealx/mcp-server

This is a Model Context Protocol (MCP) server for the DealX platform. It allows LLMs to interact with the DealX platform, specifically to search for ads.

Table of Contents

Overview

The DealX MCP Server implements the Model Context Protocol to provide a standardized way for LLMs to interact with the DealX platform. Currently, it supports searching for ads, with plans to add more functionality in the future.

What is MCP?

The Model Context Protocol (MCP) is a standardized way for LLMs to interact with external systems. It provides a structured interface for LLMs to access data and perform actions in the real world. This server implements the MCP specification to allow LLMs to interact with the DealX platform.

Available Tools

search_ads

Search for ads on the DealX platform.

Parameters:

  • query (string, optional): Search query string
  • sort (string, optional): Sort order (e.g., "-created" for newest first)
  • offset (number, optional): Pagination offset (starts at 1, default: 1)
  • limit (number, optional): Number of results per page (max 100, default: 30)

Example Usage:

{
  "query": "laptop",
  "sort": "-created",
  "offset": 1,
  "limit": 10
}

Extending the Server

The server is designed to be easily extended with additional tools. Here's how to add a new tool:

  • Define the tool in the TOOLS object in src/index.ts:

    const TOOLS = {
      SEARCH_ADS: "search_ads",
      NEW_TOOL: "new_tool", // Add your new tool here
    };
  • Create a new file in the src/tools directory for your tool implementation:

    // src/tools/new-tool.ts
    import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
    
    interface NewToolParams {
      // Define your tool parameters here
    }
    
    export async function newTool(params: NewToolParams) {
      try {
        // Implement your tool logic here
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        // Handle errors
        // ...
      }
    }
  • Add the tool to the ListToolsRequestSchema handler in src/index.ts:

    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        // Existing tools...
        {
          name: TOOLS.NEW_TOOL,
          description: "Description of your new tool",
          inputSchema: {
            type: "object",
            properties: {
              // Define your tool parameters here
            },
            required: [], // List required parameters
          },
        },
      ],
    }));
  • Add the tool to the CallToolRequestSchema handler in src/index.ts:

    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      switch (name) {
        // Existing cases...
        case TOOLS.NEW_TOOL:
          return await newTool(args);
        default:
          throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
      }
    });
  • Import your new tool in src/index.ts:

    import { newTool } from "./tools/new-tool.js";

Planned Future Tools

The following tools are planned for future implementation:

  • create_ad: Create a new ad on the DealX platform
  • edit_ad: Edit an existing ad
  • delete_ad: Delete an ad
  • get_threads: Get discussion threads for an ad
  • create_thread: Create a new discussion thread

Development

Project Structure

mcp/
โ”œโ”€โ”€ build/              # Compiled JavaScript files
โ”œโ”€โ”€ src/                # TypeScript source files
โ”‚   โ”œโ”€โ”€ tools/          # Tool implementations
โ”‚   โ”‚   โ””โ”€โ”€ search-ads.ts
โ”‚   โ””โ”€โ”€ index.ts        # Main server implementation
โ”œโ”€โ”€ .env                # Environment variables (not in git)
โ”œโ”€โ”€ .env.example        # Example environment variables
โ”œโ”€โ”€ package.json        # Project dependencies and scripts
โ”œโ”€โ”€ tsconfig.json       # TypeScript configuration
โ””โ”€โ”€ README.md           # This file

npm Scripts

  • npm run build - Compile TypeScript to JavaScript
  • npm start - Start the server using the compiled JavaScript
  • npm run dev - Start the server in development mode with hot reloading
  • npm run lint - Lint the code using ESLint
  • npm run format - Format the code using Prettier
  • npm test - Run tests