All files / src/core-entities mcp-tool.entity.ts

100% Statements 11/11
100% Branches 0/0
100% Functions 0/0
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 5845x 45x 45x                       45x             45x               45x             45x                     45x               45x    
import { Entity, Column, Index, Unique } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { BaseEntity } from './base.entity';
 
/**
 * McpTool represents a single tool exposed by an MCP server.
 * Each tool has a name, description, and input schema (JSON Schema format).
 *
 * Tools are discovered automatically when MCP servers connect.
 * Use PATCH /mcp/tools to batch enable/disable tools.
 * When is_active is true, the tool appears in the LLM's available tools list.
 */
@Entity('mcp_tools')
@Unique(['server_name', 'tool_name'])
export class McpTool extends BaseEntity {
  @ApiProperty({
    description: 'Name of the MCP server that provides this tool',
    example: 'filesystem',
  })
  @Column({ type: 'text' })
  @Index()
  server_name: string;
 
  @ApiProperty({
    description: 'Name of the tool (unique within server)',
    example: 'read_file',
  })
  @Column({ type: 'text' })
  @Index()
  tool_name: string;
 
  @ApiProperty({
    description: 'Human-readable description of what this tool does',
    example: 'Read the contents of a file from the filesystem',
  })
  @Column({ type: 'text' })
  description: string;
 
  @ApiProperty({
    description: 'JSON Schema defining the tool input parameters',
    example: {
      type: 'object',
      properties: { path: { type: 'string' } },
      required: ['path'],
    },
  })
  @Column({ type: 'json' })
  input_schema: Record<string, any>;
 
  @ApiProperty({
    description: 'Whether this tool is enabled for LLM use',
    example: true,
    default: true,
  })
  @Column({ type: 'boolean', default: true })
  is_active: boolean;
}