files.ts•5.8 kB
import { Tool } from '@modelcontextprotocol/sdk/types.js';
export const fileTools: Tool[] = [
{
name: 'get_file_content',
description: 'Retrieve the content of a specific file from a GitHub repository',
inputSchema: {
type: 'object',
properties: {
url: {
type: 'string',
description: 'GitHub repository URL',
},
filePath: {
type: 'string',
description: 'Path to the file within the repository',
},
branch: {
type: 'string',
description: 'Branch to read from (default: main/master)',
},
includeMetadata: {
type: 'boolean',
description: 'Include file metadata (size, last modified, etc.)',
default: false,
},
},
required: ['url', 'filePath'],
},
},
{
name: 'get_key_files',
description: 'Extract and analyze key files from a repository (README, config files, main entry points)',
inputSchema: {
type: 'object',
properties: {
url: {
type: 'string',
description: 'GitHub repository URL',
},
fileTypes: {
type: 'array',
items: { type: 'string' },
description: 'Types of key files to extract (e.g., ["config", "entry", "documentation"])',
},
maxSize: {
type: 'number',
description: 'Maximum file size to include (in bytes)',
default: 50000,
},
},
required: ['url'],
},
},
{
name: 'extract_functions',
description: 'Extract specific functions or classes from files',
inputSchema: {
type: 'object',
properties: {
url: {
type: 'string',
description: 'GitHub repository URL',
},
filePath: {
type: 'string',
description: 'Path to the file containing the functions',
},
functionNames: {
type: 'array',
items: { type: 'string' },
description: 'Names of functions to extract (optional - extracts all if not specified)',
},
includeDocumentation: {
type: 'boolean',
description: 'Include function documentation/comments',
default: true,
},
includeDependencies: {
type: 'boolean',
description: 'Include function dependencies and imports',
default: true,
},
},
required: ['url', 'filePath'],
},
},
{
name: 'search_code',
description: 'Search for specific code patterns, functions, or text within the repository',
inputSchema: {
type: 'object',
properties: {
url: {
type: 'string',
description: 'GitHub repository URL',
},
query: {
type: 'string',
description: 'Search query (can be regex or plain text)',
},
searchType: {
type: 'string',
enum: ['text', 'regex', 'function', 'class', 'variable'],
description: 'Type of search to perform',
default: 'text',
},
fileExtensions: {
type: 'array',
items: { type: 'string' },
description: 'File extensions to search in (e.g., [".js", ".ts"])',
},
excludePaths: {
type: 'array',
items: { type: 'string' },
description: 'Paths to exclude from search (e.g., ["node_modules", "dist"])',
},
maxResults: {
type: 'number',
description: 'Maximum number of results to return',
default: 50,
},
},
required: ['url', 'query'],
},
},
{
name: 'get_file_dependencies',
description: 'Analyze dependencies and imports for a specific file',
inputSchema: {
type: 'object',
properties: {
url: {
type: 'string',
description: 'GitHub repository URL',
},
filePath: {
type: 'string',
description: 'Path to the file to analyze',
},
includeIndirect: {
type: 'boolean',
description: 'Include indirect dependencies',
default: false,
},
resolveModules: {
type: 'boolean',
description: 'Resolve module paths to actual files',
default: true,
},
},
required: ['url', 'filePath'],
},
},
{
name: 'analyze_file_complexity',
description: 'Analyze code complexity metrics for specific files',
inputSchema: {
type: 'object',
properties: {
url: {
type: 'string',
description: 'GitHub repository URL',
},
filePaths: {
type: 'array',
items: { type: 'string' },
description: 'Paths to files to analyze',
},
metrics: {
type: 'array',
items: { type: 'string' },
description: 'Complexity metrics to calculate (e.g., ["cyclomatic", "cognitive", "lines"])',
},
},
required: ['url', 'filePaths'],
},
},
{
name: 'get_file_history',
description: 'Get commit history and changes for specific files',
inputSchema: {
type: 'object',
properties: {
url: {
type: 'string',
description: 'GitHub repository URL',
},
filePath: {
type: 'string',
description: 'Path to the file',
},
maxCommits: {
type: 'number',
description: 'Maximum number of commits to retrieve',
default: 10,
},
includeDiff: {
type: 'boolean',
description: 'Include diff information',
default: false,
},
},
required: ['url', 'filePath'],
},
},
];