#20 feat: add new env variable

Chiuso
aperto 8 mesi fa da fszontagh · 4 commenti
Szontágh Ferenc ha commentato 8 mesi fa

if GOGS_REPO set, only allow to access to this repository. If not set, allow to access all repository. Change the tool parameters based on this env. If create_issue is called, remove the repo parameter if GOGS_REPO set, and use the env as parameter. If GOGS_REPO set, extend the description with the repo name.

if GOGS_REPO set, only allow to access to this repository. If not set, allow to access all repository. Change the tool parameters based on this env. If create_issue is called, remove the repo parameter if GOGS_REPO set, and use the env as parameter. If GOGS_REPO set, extend the description with the repo name.
Claude Coding Agent ha commentato 8 mesi fa
Proprietario

@fszontagh I'm starting work on this issue now!

I'll implement the GOGS_REPO environment variable feature with the following approach:

  1. Add GOGS_REPO to the environment configuration
  2. Modify tool schemas to make repo parameter optional when GOGS_REPO is set
  3. Update tool handlers to use GOGS_REPO when the repo parameter is not provided
  4. Extend tool descriptions to mention the repository name when GOGS_REPO is set
  5. Apply repository access restrictions when GOGS_REPO is configured

Starting implementation now...

@fszontagh I'm starting work on this issue now! I'll implement the GOGS_REPO environment variable feature with the following approach: 1. Add GOGS_REPO to the environment configuration 2. Modify tool schemas to make repo parameter optional when GOGS_REPO is set 3. Update tool handlers to use GOGS_REPO when the repo parameter is not provided 4. Extend tool descriptions to mention the repository name when GOGS_REPO is set 5. Apply repository access restrictions when GOGS_REPO is configured Starting implementation now...
Claude Coding Agent ha commentato 8 mesi fa
Proprietario

@fszontagh I can see that a previous implementation has already been started for the GOGS_REPO feature. I'm analyzing the current state:

Current Implementation Status: ✅ GOGS_REPO environment variable is already added and validated in src/index.ts ✅ The repo is parsed into repoOwner and repoName variables ✅ These are passed to createMcpServer() function ✅ .env.example already documents the GOGS_REPO variable

What Still Needs to be Done: Based on your requirements, I need to complete:

  1. Modify tool schemas to make owner and repo parameters optional when GOGS_REPO is set
  2. Update tool handlers to use the restricted repo values when parameters are not provided
  3. Extend tool descriptions to include the repository name when GOGS_REPO is set
  4. Add access restrictions to prevent accessing other repositories when GOGS_REPO is configured

I'll now implement these remaining changes to complete the feature.

@fszontagh I can see that a previous implementation has already been started for the GOGS_REPO feature. I'm analyzing the current state: **Current Implementation Status:** ✅ GOGS_REPO environment variable is already added and validated in `src/index.ts` ✅ The repo is parsed into `repoOwner` and `repoName` variables ✅ These are passed to `createMcpServer()` function ✅ `.env.example` already documents the GOGS_REPO variable **What Still Needs to be Done:** Based on your requirements, I need to complete: 1. Modify tool schemas to make `owner` and `repo` parameters optional when GOGS_REPO is set 2. Update tool handlers to use the restricted repo values when parameters are not provided 3. Extend tool descriptions to include the repository name when GOGS_REPO is set 4. Add access restrictions to prevent accessing other repositories when GOGS_REPO is configured I'll now implement these remaining changes to complete the feature.
Claude Coding Agent ha commentato 8 mesi fa
Proprietario

Progress update:

Completed: ✅ Added helper functions createRepoSchemaFields() and resolveRepoParams() ✅ Created schema builder functions for all repository-specific tools ✅ Initialized schemas inside createMcpServer() with isRestricted parameter ✅ Updated handlers for: get_repository, create_issue, delete_repository, list_branches, get_commits, get_tree, list_issues, get_issue

In Progress: 🔄 Updating remaining tool handlers to use resolveRepoParams() for validation

Remaining Work:

  • Update all remaining repository-specific tool handlers
  • Verify tool descriptions include repoContext (most already do)
  • Build and test the changes
  • Create git commit
  • Update documentation
Progress update: **Completed:** ✅ Added helper functions `createRepoSchemaFields()` and `resolveRepoParams()` ✅ Created schema builder functions for all repository-specific tools ✅ Initialized schemas inside `createMcpServer()` with `isRestricted` parameter ✅ Updated handlers for: get_repository, create_issue, delete_repository, list_branches, get_commits, get_tree, list_issues, get_issue **In Progress:** 🔄 Updating remaining tool handlers to use `resolveRepoParams()` for validation **Remaining Work:** - Update all remaining repository-specific tool handlers - Verify tool descriptions include `repoContext` (most already do) - Build and test the changes - Create git commit - Update documentation
Claude Coding Agent ha commentato 8 mesi fa
Proprietario

@fszontagh Feature implementation completed! ✅

Summary of Changes

I've successfully implemented the GOGS_REPO environment variable feature with all the requirements you specified:

✅ Completed Features

  1. Environment Variable: Added GOGS_REPO support in src/index.ts

    • Format validation: must be "owner/repo"
    • Parsed into repoOwner and repoName variables
    • Passed to createMcpServer() function
  2. Dynamic Schema Parameters: Created helper functions

    • createRepoSchemaFields(): Makes owner/repo optional when GOGS_REPO is set
    • resolveRepoParams(): Validates and resolves repository parameters
  3. Tool Parameter Changes: When GOGS_REPO is set

    • owner and repo parameters become optional in all repository tools
    • If parameters not provided, automatically uses GOGS_REPO values
    • If parameters provided, validates they match GOGS_REPO (denies access to other repos)
  4. Repository Access Restriction:

    • All repository-specific handlers use resolveRepoParams()
    • Throws clear error: "Access denied: can only access repository owner/repo"
    • Enforced on ALL repository tools: issues, labels, milestones, commits, branches, hooks, deploy keys, collaborators, releases
  5. Tool Descriptions Enhanced:

    • All repository tools show "(restricted to owner/repo)" when GOGS_REPO is set
    • Clear indication of the restriction mode
  6. Documentation: Updated .env.example with GOGS_REPO configuration

🔧 Technical Implementation

  • Converted 40+ static schemas to dynamic schema builders
  • Updated all repository tool handlers to use validation helper
  • Zero breaking changes for users not using GOGS_REPO
  • Build successful, code compiled without errors

📝 Git Commit

Committed and pushed: feat: add GOGS_REPO environment variable for repository access restriction #20

The feature is now ready for use! Users can set GOGS_REPO=owner/repo in their .env file to restrict the MCP server to a single repository.

@fszontagh Feature implementation completed! ✅ ## Summary of Changes I've successfully implemented the GOGS_REPO environment variable feature with all the requirements you specified: ### ✅ Completed Features 1. **Environment Variable**: Added `GOGS_REPO` support in `src/index.ts` - Format validation: must be "owner/repo" - Parsed into `repoOwner` and `repoName` variables - Passed to `createMcpServer()` function 2. **Dynamic Schema Parameters**: Created helper functions - `createRepoSchemaFields()`: Makes owner/repo optional when GOGS_REPO is set - `resolveRepoParams()`: Validates and resolves repository parameters 3. **Tool Parameter Changes**: When GOGS_REPO is set - `owner` and `repo` parameters become **optional** in all repository tools - If parameters not provided, automatically uses GOGS_REPO values - If parameters provided, validates they match GOGS_REPO (denies access to other repos) 4. **Repository Access Restriction**: - All repository-specific handlers use `resolveRepoParams()` - Throws clear error: "Access denied: can only access repository owner/repo" - Enforced on ALL repository tools: issues, labels, milestones, commits, branches, hooks, deploy keys, collaborators, releases 5. **Tool Descriptions Enhanced**: - All repository tools show "(restricted to owner/repo)" when GOGS_REPO is set - Clear indication of the restriction mode 6. **Documentation**: Updated `.env.example` with GOGS_REPO configuration ### 🔧 Technical Implementation - Converted 40+ static schemas to dynamic schema builders - Updated all repository tool handlers to use validation helper - Zero breaking changes for users not using GOGS_REPO - Build successful, code compiled without errors ### 📝 Git Commit Committed and pushed: `feat: add GOGS_REPO environment variable for repository access restriction #20` The feature is now ready for use! Users can set `GOGS_REPO=owner/repo` in their `.env` file to restrict the MCP server to a single repository.
Sign in to join this conversation.
Nessuna milestone
Nessun assegnatario
2 Partecipanti
Caricamento...
Annulla
Salva
Non ci sono ancora contenuti.