Skip to content

Commit 6b0ad43

Browse files
fix circular dep & refactor tool names types
1 parent 9f1ccda commit 6b0ad43

25 files changed

+119
-132
lines changed

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from '@modelcontextprotocol/sdk/types.js';
99
import { OpenAPI } from './src/api/client/index.js';
1010
import * as Tools from './src/tools/index.js';
11-
import type { ToolKeys } from './src/tools/index.js';
11+
import type { ToolKeys } from './src/schemas.js';
1212
import * as Handlers from './src/handlers/index.js';
1313
import { validateOrganization } from './src/middleware/validation.js';
1414

src/rules.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { toolNames } from './schemas.js';
2+
3+
// General rules pertaining to the accuracy of the arguments passed to the tools
4+
export const generalOrganizationMistakes = `
5+
- Using this tool for a organization other than the current one
6+
- Using this tool with the wrong organization name (if you are not sure, use the ${toolNames.CODACY_LIST_ORGANIZATIONS} tool to validate the organization name)
7+
`;
8+
9+
export const generalRepositoryMistakes = `
10+
- Using this tool without specifying the repository name
11+
- Using this tool for a repository other than the current one
12+
- Using this tool with the wrong repository name (if you are not sure, use the ${toolNames.CODACY_LIST_ORGANIZATION_REPOSITORIES} tool to validate the repository name)
13+
`;

src/schemas.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
2+
3+
export const toolNames = {
4+
CODACY_LIST_ORGANIZATION_REPOSITORIES: 'codacy_list_organization_repositories',
5+
CODACY_LIST_SRM_ITEMS: 'codacy_list_srm_items',
6+
CODACY_LIST_REPOSITORY_ISSUES: 'codacy_list_repository_issues',
7+
CODACY_LIST_REPOSITORY_PULL_REQUESTS: 'codacy_list_repository_pull_requests',
8+
CODACY_LIST_FILES: 'codacy_list_files',
9+
CODACY_LIST_REPOSITORY_TOOL_PATTERNS: 'codacy_list_repository_tool_patterns',
10+
CODACY_LIST_REPOSITORY_TOOLS: 'codacy_list_repository_tools',
11+
CODACY_LIST_TOOLS: 'codacy_list_tools',
12+
CODACY_LIST_ORGANIZATIONS: 'codacy_list_organizations',
13+
CODACY_GET_FILE_ISSUES: 'codacy_get_file_issues',
14+
CODACY_GET_FILE_COVERAGE: 'codacy_get_file_coverage',
15+
CODACY_GET_REPOSITORY_PULL_REQUEST_FILES_COVERAGE:
16+
'codacy_get_repository_pull_request_files_coverage',
17+
CODACY_GET_PULL_REQUEST_GIT_DIFF: 'codacy_get_pull_request_git_diff',
18+
CODACY_LIST_PULL_REQUEST_ISSUES: 'codacy_list_pull_request_issues',
19+
CODACY_GET_REPOSITORY_WITH_ANALYSIS: 'codacy_get_repository_with_analysis',
20+
CODACY_GET_FILE_WITH_ANALYSIS: 'codacy_get_file_with_analysis',
21+
CODACY_GET_REPOSITORY_PULL_REQUEST: 'codacy_get_repository_pull_request',
22+
CODACY_GET_ISSUE: 'codacy_get_issue',
23+
CODACY_GET_PATTERN: 'codacy_get_pattern',
24+
CODACY_CLI_ANALYZE: 'codacy_cli_analyze',
25+
} as const;
26+
27+
export type ToolKeys = (typeof toolNames)[keyof typeof toolNames];
28+
29+
export interface CodacyTool extends Tool {
30+
name: ToolKeys;
31+
}
32+
133
export const organizationSchema = {
234
gitUrl: {
335
type: 'string',

src/tools/cliAnalyzeTool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Tool } from '@modelcontextprotocol/sdk/types.js';
1+
import { CodacyTool, toolNames } from '../schemas.js';
22

33
export const allowedTools = ['eslint'];
44

5-
export const cliAnalyzeTool: Tool = {
6-
name: 'codacy_cli_analyze',
5+
export const cliAnalyzeTool: CodacyTool = {
6+
name: toolNames.CODACY_CLI_ANALYZE,
77
description:
88
'Run quality analysis using Codacy CLI. Requires the Codacy CLI to be installed and configured.',
99
inputSchema: {

src/tools/getFileCoverageTool.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { Tool } from '@modelcontextprotocol/sdk/types.js';
2-
import { fileSchema } from '../schemas.js';
1+
import { CodacyTool, fileSchema, toolNames } from '../schemas.js';
32

4-
export const getFileCoverageTool: Tool = {
5-
name: 'codacy_get_file_coverage',
3+
export const getFileCoverageTool: CodacyTool = {
4+
name: toolNames.CODACY_GET_FILE_COVERAGE,
65
description: 'Get coverage information for a file in the head commit of a repository branch.',
76
inputSchema: {
87
type: 'object',

src/tools/getFileWithAnalysisTool.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { Tool } from '@modelcontextprotocol/sdk/types.js';
2-
import { fileSchema } from '../schemas.js';
1+
import { CodacyTool, fileSchema, toolNames } from '../schemas.js';
32

4-
export const getFileWithAnalysisTool: Tool = {
5-
name: 'codacy_get_file_with_analysis',
3+
export const getFileWithAnalysisTool: CodacyTool = {
4+
name: toolNames.CODACY_GET_FILE_WITH_ANALYSIS,
65
description:
76
"Get file information and it's analysis information and coverage metrics. A file that is ignored is not analyzed by Codacy. Here you will find results for five metrics: Grade, Issues, Duplication, Complexity and Coverage.",
87
inputSchema: {

src/tools/getIssueTool.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { Tool } from '@modelcontextprotocol/sdk/types.js';
2-
import { repositorySchema } from '../schemas.js';
1+
import { CodacyTool, repositorySchema, toolNames } from '../schemas.js';
32

4-
export const getIssueTool: Tool = {
5-
name: 'codacy_get_issue',
3+
export const getIssueTool: CodacyTool = {
4+
name: toolNames.CODACY_GET_ISSUE,
65
description: 'Returns information about an open issue that Codacy found in a repository.',
76
inputSchema: {
87
type: 'object',

src/tools/getPatternTool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Tool } from '@modelcontextprotocol/sdk/types.js';
1+
import { CodacyTool, toolNames } from '../schemas.js';
22

3-
export const getPatternTool: Tool = {
4-
name: 'codacy_get_pattern',
3+
export const getPatternTool: CodacyTool = {
4+
name: toolNames.CODACY_GET_PATTERN,
55
description: 'Get the definition of a specific pattern.',
66
inputSchema: {
77
type: 'object' as const,

src/tools/getPullRequestGitDiffTool.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { Tool } from '@modelcontextprotocol/sdk/types.js';
2-
import { repositorySchema } from '../schemas.js';
1+
import { CodacyTool, repositorySchema, toolNames } from '../schemas.js';
32

4-
export const getPullRequestGitDiffTool: Tool = {
5-
name: 'codacy_get_pull_request_git_diff',
3+
export const getPullRequestGitDiffTool: CodacyTool = {
4+
name: toolNames.CODACY_GET_PULL_REQUEST_GIT_DIFF,
65
description: 'Returns the human-readable Git diff of a pull request',
76
inputSchema: {
87
type: 'object',

src/tools/getRepositoryPullRequestFilesCoverageTool.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { Tool } from '@modelcontextprotocol/sdk/types.js';
2-
import { repositorySchema } from '../schemas.js';
1+
import { CodacyTool, repositorySchema, toolNames } from '../schemas.js';
32

4-
export const getRepositoryPullRequestFilesCoverageTool: Tool = {
5-
name: 'codacy_get_repository_pull_request_files_coverage',
3+
export const getRepositoryPullRequestFilesCoverageTool: CodacyTool = {
4+
name: toolNames.CODACY_GET_REPOSITORY_PULL_REQUEST_FILES_COVERAGE,
65
description: 'Get coverage information for all files in a pull request.',
76
inputSchema: {
87
type: 'object',

0 commit comments

Comments
 (0)