From 5ceab6eb2421f98598f7e04c28289739fe9a1e93 Mon Sep 17 00:00:00 2001 From: Ismar Iljazovic Date: Tue, 30 Dec 2025 10:52:47 +0100 Subject: [PATCH] fix: add knip config, pre-commit hook, fix Zod compatibility, and remove unused code --- .beads/issues.jsonl | 2 +- .pre-commit-config.yaml | 12 ++++++++++-- knip.json | 6 ++++++ src/registry/index.ts | 6 ++---- src/registry/tool-adapter.ts | 2 +- src/registry/tool-registry.ts | 17 ++--------------- src/utils/gitlab-client.ts | 5 ----- src/utils/index.ts | 9 --------- src/utils/logger.ts | 16 ---------------- 9 files changed, 22 insertions(+), 53 deletions(-) create mode 100644 knip.json delete mode 100644 src/utils/index.ts diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl index c1c5ee6c..d0723d50 100644 --- a/.beads/issues.jsonl +++ b/.beads/issues.jsonl @@ -3,7 +3,7 @@ {"id":"efficient-gitlab-mcp-5zo","title":"Add pipeline/CI tools to efficient-gitlab-mcp","description":"Add GitLab pipeline-related tools: list pipelines, get pipeline details, trigger pipelines, get jobs, view job logs, retry/cancel jobs.","status":"closed","priority":1,"issue_type":"feature","created_at":"2025-12-24T18:38:34.590242+01:00","updated_at":"2025-12-24T18:39:30.349119+01:00","closed_at":"2025-12-24T18:39:30.349119+01:00","close_reason":"Pipeline tools already implemented: list_pipelines, get_pipeline, create_pipeline, retry_pipeline, cancel_pipeline, list_pipeline_jobs, get_pipeline_job_output, play_pipeline_job, retry_pipeline_job, cancel_pipeline_job. Tests exist in tools.test.ts.","labels":["feature","tools"]} {"id":"efficient-gitlab-mcp-6am","title":"Publish to MCP Registry","description":"Register efficient-gitlab-mcp on the official MCP Registry for discoverability.","status":"closed","priority":2,"issue_type":"feature","created_at":"2025-12-29T12:49:57.881217+01:00","updated_at":"2025-12-29T13:23:50.513312+01:00","closed_at":"2025-12-29T13:23:50.513312+01:00","close_reason":"Published to MCP Registry"} {"id":"efficient-gitlab-mcp-9af","title":"Enable NPM publishing for efficient-gitlab-mcp","description":"Configure semantic-release to publish to NPM. Update .releaserc.json to enable npmPublish.\n\n**After publishing:**\n- Update README installation instructions to use `npx @detailobsessed/efficient-gitlab-mcp` instead of cloning the repo\n- Remove instructions about pointing MCP clients to `.../dist/index.js`\n- Add npm badge to README","notes":"**Progress:**\n- ✅ Updated npm-publish.yml workflow with Bun build, provenance, and NPM_TOKEN\n- ✅ Added workflow_dispatch for manual runs\n- ⏳ Need to add NPM_TOKEN secret to GitHub repo\n\n**To complete:**\n1. Create NPM access token at https://www.npmjs.com/settings/tokens\n2. Add as GitHub secret: `gh secret set NPM_TOKEN --repo detailobsessed/efficient-gitlab-mcp`\n3. Trigger a release or run workflow manually to publish","status":"closed","priority":2,"issue_type":"task","created_at":"2025-12-24T18:38:32.177275+01:00","updated_at":"2025-12-25T14:01:09.344799+01:00","closed_at":"2025-12-25T14:01:09.344799+01:00","close_reason":"NPM publishing configured with Trusted Publishing (OIDC). Package published as efficient-gitlab-mcp-server v0.1.1. Workflow updated to use OIDC instead of NPM_TOKEN.","labels":["npm","publishing"]} -{"id":"efficient-gitlab-mcp-a3x","title":"Clean up unused upstream dependencies and test files","description":"knip identified unused code from upstream:\n\n**Unused dependencies (11) - REMOVED:**\n- fetch-cookie, form-data, http-proxy-agent, https-proxy-agent, node-fetch, open, pkce-challenge, socks-proxy-agent, tough-cookie, zod-to-json-schema, @types/express\n\n**Upstream test files (19) - NEED REVIEW:**\n- Some tests work with bun (readonly-mcp-tests.ts)\n- Some are broken (oauth-tests.ts imports non-existent ../oauth.js)\n- Some depend on removed packages (remote-auth-tests.ts uses node-fetch)\n\nNext steps:\n1. Review each test file\n2. Fix or remove broken tests\n3. Keep working integration tests for use on work laptop with GitLab access","status":"open","priority":2,"issue_type":"chore","created_at":"2025-12-30T10:15:21.899203+01:00","updated_at":"2025-12-30T10:27:08.725345+01:00"} +{"id":"efficient-gitlab-mcp-a3x","title":"Clean up unused upstream dependencies and test files","description":"knip identified unused code from upstream:\n\n**Unused dependencies (11) - REMOVED:**\n- fetch-cookie, form-data, http-proxy-agent, https-proxy-agent, node-fetch, open, pkce-challenge, socks-proxy-agent, tough-cookie, zod-to-json-schema, @types/express\n\n**Upstream test files (19) - NEED REVIEW:**\n- Some tests work with bun (readonly-mcp-tests.ts)\n- Some are broken (oauth-tests.ts imports non-existent ../oauth.js)\n- Some depend on removed packages (remote-auth-tests.ts uses node-fetch)\n\nNext steps:\n1. Review each test file\n2. Fix or remove broken tests\n3. Keep working integration tests for use on work laptop with GitLab access","status":"closed","priority":2,"issue_type":"chore","created_at":"2025-12-30T10:15:21.899203+01:00","updated_at":"2025-12-30T10:35:24.138971+01:00","closed_at":"2025-12-30T10:35:24.138971+01:00","close_reason":"Removed 11 unused dependencies (PR #36), deleted broken oauth-tests.ts, fixed remote-auth-tests.ts to use native fetch (PR #37)"} {"id":"efficient-gitlab-mcp-b50","title":"Create server.json for MCP Registry","description":"Create server.json metadata file with environment variables","status":"closed","priority":2,"issue_type":"task","created_at":"2025-12-29T12:50:04.053915+01:00","updated_at":"2025-12-29T12:50:38.353663+01:00","closed_at":"2025-12-29T12:50:38.353663+01:00","close_reason":"Completed","dependencies":[{"issue_id":"efficient-gitlab-mcp-b50","depends_on_id":"efficient-gitlab-mcp-6am","type":"blocks","created_at":"2025-12-29T12:50:04.064925+01:00","created_by":"daemon"}]} {"id":"efficient-gitlab-mcp-fbp","title":"Add DNS rebinding protection for HTTP transport","description":"When using StreamableHTTPServerTransport, enable DNS rebinding protection for security:\n\n```typescript\nnew StreamableHTTPServerTransport({\n enableDnsRebindingProtection: true,\n allowedHosts: ['localhost', '127.0.0.1'],\n allowedOrigins: ['http://localhost:3000']\n});\n```\n\nThis prevents malicious websites from making requests to the local MCP server.","status":"closed","priority":3,"issue_type":"task","created_at":"2025-12-24T16:20:34.579748+01:00","updated_at":"2025-12-24T16:38:33.572059+01:00","closed_at":"2025-12-24T16:38:33.572059+01:00","close_reason":"Added DNS rebinding protection with configurable allowedHosts and allowedOrigins","labels":["http-transport","mcp-sdk","security"]} {"id":"efficient-gitlab-mcp-h2f","title":"Add mcpName to package.json","description":"Add mcpName property for MCP Registry verification","status":"closed","priority":2,"issue_type":"task","created_at":"2025-12-29T12:50:02.981651+01:00","updated_at":"2025-12-29T12:50:20.779683+01:00","closed_at":"2025-12-29T12:50:20.779683+01:00","close_reason":"Completed","dependencies":[{"issue_id":"efficient-gitlab-mcp-h2f","depends_on_id":"efficient-gitlab-mcp-6am","type":"blocks","created_at":"2025-12-29T12:50:02.987921+01:00","created_by":"daemon"}]} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f04f445d..391623fe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,13 +40,21 @@ repos: types: [ts] priority: 1 + - id: knip + name: knip + entry: bunx knip + language: system + pass_filenames: false + types: [ts] + priority: 2 + - id: build name: Build entry: bun run build language: system pass_filenames: false types: [ts] - priority: 2 + priority: 3 - id: test name: Run Tests @@ -54,7 +62,7 @@ repos: language: system pass_filenames: false stages: [pre-push] - priority: 3 + priority: 4 - repo: https://github.com/compilerla/conventional-pre-commit rev: v4.3.0 diff --git a/knip.json b/knip.json new file mode 100644 index 00000000..05ea2f6c --- /dev/null +++ b/knip.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://unpkg.com/knip@5.30.6/schema.json", + "entry": ["src/server/index.ts"], + "project": ["src/**/*.ts"], + "ignore": ["test/**"] +} diff --git a/src/registry/index.ts b/src/registry/index.ts index 733869a7..e9ffdfd3 100644 --- a/src/registry/index.ts +++ b/src/registry/index.ts @@ -1,5 +1,3 @@ export { registerMetaTools } from "./meta-tools.js"; -export type { ToolRegistrationTarget } from "./tool-adapter.js"; -export { createRegistryAdapter, RegistryAdapter } from "./tool-adapter.js"; -export type { CategoryInfo, ToolHandler, ToolInfo, ToolSummary } from "./tool-registry.js"; -export { getRegistry, resetRegistry, ToolRegistry } from "./tool-registry.js"; +export { createRegistryAdapter } from "./tool-adapter.js"; +export { ToolRegistry } from "./tool-registry.js"; diff --git a/src/registry/tool-adapter.ts b/src/registry/tool-adapter.ts index c4456809..de091922 100644 --- a/src/registry/tool-adapter.ts +++ b/src/registry/tool-adapter.ts @@ -41,7 +41,7 @@ export interface ToolRegistrationTarget { ): void; } -export class RegistryAdapter implements ToolRegistrationTarget { +class RegistryAdapter implements ToolRegistrationTarget { constructor( private registry: ToolRegistry, private category: string, diff --git a/src/registry/tool-registry.ts b/src/registry/tool-registry.ts index 0c170426..7ff8c68d 100644 --- a/src/registry/tool-registry.ts +++ b/src/registry/tool-registry.ts @@ -7,7 +7,8 @@ * Pattern inspired by unblu-mcp and efficient-discord-agent-mcp servers. */ -import type { ZodType } from "zod"; +// biome-ignore lint/suspicious/noExplicitAny: Required for Zod v3/v4 compatibility +type ZodType = any; export interface ToolInfo { name: string; @@ -393,17 +394,3 @@ interface ZodDef { minLength?: { value: number }; maxLength?: { value: number }; } - -// Global registry instance -let registryInstance: ToolRegistry | null = null; - -export function getRegistry(): ToolRegistry { - if (!registryInstance) { - registryInstance = new ToolRegistry(); - } - return registryInstance; -} - -export function resetRegistry(): void { - registryInstance = null; -} diff --git a/src/utils/gitlab-client.ts b/src/utils/gitlab-client.ts index 34c6d6e1..bfae67aa 100644 --- a/src/utils/gitlab-client.ts +++ b/src/utils/gitlab-client.ts @@ -10,11 +10,6 @@ export interface FetchOptions { body?: string; } -export interface GitLabClientConfig { - apiUrl: string; - token?: string; -} - export class GitLabClient { private apiUrl: string; private token: string; diff --git a/src/utils/index.ts b/src/utils/index.ts deleted file mode 100644 index 20545314..00000000 --- a/src/utils/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export type { FetchOptions, GitLabClientConfig } from "./gitlab-client.js"; -export { - buildQueryString, - defaultClient, - encodeProjectId, - GitLabClient, -} from "./gitlab-client.js"; -export type { LogContext, LogFormat, LogLevel } from "./logger.js"; -export { Logger } from "./logger.js"; diff --git a/src/utils/logger.ts b/src/utils/logger.ts index fa7fdb3d..8c321336 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -125,19 +125,3 @@ export class Logger { } } } - -// Default logger instance -let defaultLogger: Logger | null = null; - -export function getLogger(): Logger { - if (!defaultLogger) { - const level = (process.env.LOG_LEVEL as LogLevel) || "info"; - const format = (process.env.LOG_FORMAT as LogFormat) || "pretty"; - defaultLogger = new Logger(level, format); - } - return defaultLogger; -} - -export function setLogger(logger: Logger): void { - defaultLogger = logger; -}