@andrebuzeli/git-mcp 4.0.20 → 4.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +7 -239
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -221
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +11 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -16
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +1 -69
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +150 -711
- package/dist/server.js.map +1 -1
- package/dist/tools/git-analytics.d.ts +1 -0
- package/dist/tools/git-analytics.d.ts.map +1 -1
- package/dist/tools/git-analytics.js +18 -7
- package/dist/tools/git-analytics.js.map +1 -1
- package/dist/tools/git-archive.d.ts +2 -149
- package/dist/tools/git-archive.d.ts.map +1 -1
- package/dist/tools/git-archive.js +5 -222
- package/dist/tools/git-archive.js.map +1 -1
- package/dist/tools/git-backup.d.ts +1 -198
- package/dist/tools/git-backup.d.ts.map +1 -1
- package/dist/tools/git-backup.js +4 -805
- package/dist/tools/git-backup.js.map +1 -1
- package/dist/tools/git-branches.d.ts +1 -158
- package/dist/tools/git-branches.d.ts.map +1 -1
- package/dist/tools/git-branches.js +4 -539
- package/dist/tools/git-branches.js.map +1 -1
- package/dist/tools/git-config.d.ts +2 -124
- package/dist/tools/git-config.d.ts.map +1 -1
- package/dist/tools/git-config.js +5 -263
- package/dist/tools/git-config.js.map +1 -1
- package/dist/tools/git-files.d.ts +2 -115
- package/dist/tools/git-files.d.ts.map +1 -1
- package/dist/tools/git-files.js +161 -407
- package/dist/tools/git-files.js.map +1 -1
- package/dist/tools/git-issues.d.ts +1 -214
- package/dist/tools/git-issues.d.ts.map +1 -1
- package/dist/tools/git-issues.js +4 -678
- package/dist/tools/git-issues.js.map +1 -1
- package/dist/tools/git-monitor.d.ts +1 -143
- package/dist/tools/git-monitor.d.ts.map +1 -1
- package/dist/tools/git-monitor.js +4 -738
- package/dist/tools/git-monitor.js.map +1 -1
- package/dist/tools/git-packages.d.ts +2 -91
- package/dist/tools/git-packages.d.ts.map +1 -1
- package/dist/tools/git-packages.js +5 -258
- package/dist/tools/git-packages.js.map +1 -1
- package/dist/tools/git-pulls.d.ts +1 -63
- package/dist/tools/git-pulls.d.ts.map +1 -1
- package/dist/tools/git-pulls.js +4 -77
- package/dist/tools/git-pulls.js.map +1 -1
- package/dist/tools/git-release.d.ts +1 -169
- package/dist/tools/git-release.d.ts.map +1 -1
- package/dist/tools/git-release.js +4 -611
- package/dist/tools/git-release.js.map +1 -1
- package/dist/tools/git-remote.d.ts +1 -153
- package/dist/tools/git-remote.d.ts.map +1 -1
- package/dist/tools/git-remote.js +4 -555
- package/dist/tools/git-remote.js.map +1 -1
- package/dist/tools/git-reset.d.ts +1 -157
- package/dist/tools/git-reset.d.ts.map +1 -1
- package/dist/tools/git-reset.js +4 -597
- package/dist/tools/git-reset.js.map +1 -1
- package/dist/tools/git-stash.d.ts +1 -161
- package/dist/tools/git-stash.d.ts.map +1 -1
- package/dist/tools/git-stash.js +4 -640
- package/dist/tools/git-stash.js.map +1 -1
- package/dist/tools/git-sync.d.ts +1 -0
- package/dist/tools/git-sync.d.ts.map +1 -1
- package/dist/tools/git-sync.js +13 -7
- package/dist/tools/git-sync.js.map +1 -1
- package/dist/tools/git-tags.d.ts +1 -162
- package/dist/tools/git-tags.d.ts.map +1 -1
- package/dist/tools/git-tags.js +4 -549
- package/dist/tools/git-tags.js.map +1 -1
- package/dist/tools/git-workflow.d.ts +3 -96
- package/dist/tools/git-workflow.d.ts.map +1 -1
- package/dist/tools/git-workflow.js +287 -314
- package/dist/tools/git-workflow.js.map +1 -1
- package/package.json +3 -3
- package/dist/server-minimal.d.ts +0 -8
- package/dist/server-minimal.d.ts.map +0 -1
- package/dist/server-minimal.js +0 -218
- package/dist/server-minimal.js.map +0 -1
package/dist/server.js
CHANGED
|
@@ -6,201 +6,80 @@ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
|
6
6
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
7
7
|
const config_js_1 = require("./config.js");
|
|
8
8
|
const index_js_2 = require("./providers/index.js");
|
|
9
|
+
// Import all tools
|
|
10
|
+
const git_workflow_js_1 = require("./tools/git-workflow.js");
|
|
11
|
+
const git_files_js_1 = require("./tools/git-files.js");
|
|
12
|
+
const git_branches_js_1 = require("./tools/git-branches.js");
|
|
13
|
+
const git_issues_js_1 = require("./tools/git-issues.js");
|
|
14
|
+
const git_pulls_js_1 = require("./tools/git-pulls.js");
|
|
15
|
+
const git_tags_js_1 = require("./tools/git-tags.js");
|
|
16
|
+
const git_release_js_1 = require("./tools/git-release.js");
|
|
17
|
+
const git_remote_js_1 = require("./tools/git-remote.js");
|
|
18
|
+
const git_reset_js_1 = require("./tools/git-reset.js");
|
|
19
|
+
const git_stash_js_1 = require("./tools/git-stash.js");
|
|
20
|
+
const git_config_js_1 = require("./tools/git-config.js");
|
|
21
|
+
const git_monitor_js_1 = require("./tools/git-monitor.js");
|
|
22
|
+
const git_backup_js_1 = require("./tools/git-backup.js");
|
|
23
|
+
const git_archive_js_1 = require("./tools/git-archive.js");
|
|
24
|
+
const git_packages_js_1 = require("./tools/git-packages.js");
|
|
25
|
+
const git_analytics_js_1 = require("./tools/git-analytics.js");
|
|
26
|
+
const git_sync_js_1 = require("./tools/git-sync.js");
|
|
27
|
+
const git_repos_js_1 = require("./tools/git-repos.js");
|
|
9
28
|
/**
|
|
10
|
-
*
|
|
29
|
+
* Servidor MCP Git Completo com 18 Tools Oficiais
|
|
11
30
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* - Auto-detecção universal (repo, owner, providers)
|
|
15
|
-
* - Interface consistente para todos os AI agents/IDEs
|
|
16
|
-
* - Error handling com recovery automático
|
|
17
|
-
* - Foco em produtividade individual e backup
|
|
18
|
-
*
|
|
19
|
-
* CORE UNIFIED TOOLS (6) - FUNCIONALIDADES ESSENCIAIS:
|
|
20
|
-
* - git-workflow: Workflow completo (init, commit, sync, status, backup)
|
|
21
|
-
* - git-files: Operações inteligentes de arquivo (read, write, search, update, backup-files)
|
|
22
|
-
* - git-release: Sistema de release automatizado (create, version, publish, history, rollback)
|
|
23
|
-
* - git-monitor: Monitoramento avançado (status, history, metrics, health, activity)
|
|
24
|
-
* - git-backup: Sistema de backup inteligente (create, restore, list, auto, verify)
|
|
25
|
-
* - git-branches: Gerenciamento de branches unificado
|
|
26
|
-
*
|
|
27
|
-
* ADVANCED TOOLS (6) - FUNCIONALIDADES AVANÇADAS:
|
|
28
|
-
* - git-remote: Gerenciamento de remotos
|
|
29
|
-
* - git-stash: Operações de stash
|
|
30
|
-
* - git-reset: Reset seguro
|
|
31
|
-
* - git-tags: Gerenciamento de tags
|
|
32
|
-
* - git-issues: Sistema de issues
|
|
33
|
-
* - git-pulls: Pull requests
|
|
34
|
-
*
|
|
35
|
-
* SPECIALIZED TOOLS (6) - FUNCIONALIDADES ESPECÍFICAS:
|
|
36
|
-
* - git-analytics: Analytics e relatórios
|
|
37
|
-
* - git-archive: Operações de archive
|
|
38
|
-
* - git-packages: Gerenciamento de pacotes
|
|
39
|
-
* - git-sync: Sincronização multi-provider
|
|
40
|
-
* - git-repos: Gerenciamento de repositórios
|
|
41
|
-
* - git-config: Configurações avançadas
|
|
42
|
-
*
|
|
43
|
-
* DIFERENCIAIS IMPLEMENTADOS:
|
|
44
|
-
* - Apenas action + projectPath obrigatórios
|
|
45
|
-
* - Auto-detecção completa de contexto
|
|
46
|
-
* - Respostas estruturadas universais
|
|
47
|
-
* - Error handling inteligente com sugestões
|
|
48
|
-
* - Multi-provider automático
|
|
49
|
-
* - Interface compatível com qualquer AI agent/IDE
|
|
50
|
-
*/
|
|
51
|
-
// CORE UNIFIED TOOLS (6 ferramentas essenciais)
|
|
52
|
-
const git_workflow_js_1 = require("./tools/git-workflow.js"); // Workflow unificado
|
|
53
|
-
const git_files_js_1 = require("./tools/git-files.js"); // Operações de arquivo inteligentes
|
|
54
|
-
const git_release_js_1 = require("./tools/git-release.js"); // Sistema de release automatizado
|
|
55
|
-
const git_monitor_js_1 = require("./tools/git-monitor.js"); // Monitoramento avançado
|
|
56
|
-
const git_backup_js_1 = require("./tools/git-backup.js"); // Sistema de backup inteligente
|
|
57
|
-
const git_branches_js_1 = require("./tools/git-branches.js"); // Gerenciamento de branches
|
|
58
|
-
// ADVANCED TOOLS (6 ferramentas avançadas)
|
|
59
|
-
const git_remote_js_1 = require("./tools/git-remote.js"); // Gerenciamento de remotos
|
|
60
|
-
const git_stash_js_1 = require("./tools/git-stash.js"); // Operações de stash
|
|
61
|
-
const git_reset_js_1 = require("./tools/git-reset.js"); // Reset seguro
|
|
62
|
-
const git_tags_js_1 = require("./tools/git-tags.js"); // Gerenciamento de tags
|
|
63
|
-
const git_issues_js_1 = require("./tools/git-issues.js"); // Sistema de issues
|
|
64
|
-
const git_pulls_js_1 = require("./tools/git-pulls.js"); // Pull requests
|
|
65
|
-
// SPECIALIZED TOOLS (6 ferramentas especializadas)
|
|
66
|
-
const git_analytics_js_1 = require("./tools/git-analytics.js"); // Analytics e relatórios
|
|
67
|
-
const git_archive_js_1 = require("./tools/git-archive.js"); // Operações de archive
|
|
68
|
-
const git_packages_js_1 = require("./tools/git-packages.js"); // Gerenciamento de pacotes
|
|
69
|
-
const git_sync_js_1 = require("./tools/git-sync.js"); // Sincronização multi-provider
|
|
70
|
-
const git_repos_js_1 = require("./tools/git-repos.js"); // Gerenciamento de repositórios
|
|
71
|
-
const git_config_js_1 = require("./tools/git-config.js"); // Configurações avançadas
|
|
72
|
-
/**
|
|
73
|
-
* Array de todas as ferramentas disponíveis (18 tools) - UNIFICADAS
|
|
74
|
-
*
|
|
75
|
-
* ARQUITETURA UNIFICADA MCP GIT AI UNIFICATION:
|
|
76
|
-
* - 18 ferramentas otimizadas para AI agents
|
|
77
|
-
* - Interface universal para qualquer IDE (VSCode, Cursor, Trae)
|
|
78
|
-
* - Apenas action + projectPath obrigatórios
|
|
79
|
-
* - Auto-detecção completa de contexto
|
|
80
|
-
* - Error handling inteligente com recovery
|
|
81
|
-
* - Foco em produtividade individual e backup
|
|
82
|
-
*
|
|
83
|
-
* CORE UNIFIED TOOLS (6 ferramentas essenciais):
|
|
84
|
-
* - git-workflow: Workflow completo (init, commit, sync, status, backup)
|
|
85
|
-
* - git-files: Operações inteligentes de arquivo (read, write, search, update, backup-files)
|
|
86
|
-
* - git-release: Sistema de release automatizado (create, version, publish, history, rollback)
|
|
87
|
-
* - git-monitor: Monitoramento avançado (status, history, metrics, health, activity)
|
|
88
|
-
* - git-backup: Sistema de backup inteligente (create, restore, list, auto, verify)
|
|
89
|
-
* - git-branches: Gerenciamento de branches unificado
|
|
90
|
-
*
|
|
91
|
-
* ADVANCED TOOLS (6 ferramentas avançadas):
|
|
92
|
-
* - git-remote: Gerenciamento de remotos
|
|
93
|
-
* - git-stash: Operações de stash
|
|
94
|
-
* - git-reset: Reset seguro
|
|
95
|
-
* - git-tags: Gerenciamento de tags
|
|
96
|
-
* - git-issues: Sistema de issues
|
|
97
|
-
* - git-pulls: Pull requests
|
|
98
|
-
*
|
|
99
|
-
* SPECIALIZED TOOLS (6 ferramentas especializadas):
|
|
100
|
-
* - git-analytics: Analytics e relatórios
|
|
101
|
-
* - git-archive: Operações de archive
|
|
102
|
-
* - git-packages: Gerenciamento de pacotes
|
|
103
|
-
* - git-sync: Sincronização multi-provider
|
|
104
|
-
* - git-repos: Gerenciamento de repositórios
|
|
105
|
-
* - git-config: Configurações avançadas
|
|
106
|
-
*
|
|
107
|
-
* DIFERENCIAIS IMPLEMENTADOS:
|
|
108
|
-
* - Auto-detecção universal (repo, owner, providers)
|
|
109
|
-
* - Respostas estruturadas consistentes
|
|
110
|
-
* - Multi-provider automático
|
|
111
|
-
* - Error handling com sugestões de recovery
|
|
112
|
-
* - Interface compatível com qualquer AI agent
|
|
31
|
+
* Este servidor implementa todas as 18 ferramentas Git conforme especificado
|
|
32
|
+
* no design, com auto-detecção universal e suporte multi-provider.
|
|
113
33
|
*/
|
|
34
|
+
// Lista completa das 18 tools oficiais
|
|
114
35
|
const tools = [
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
git_stash_js_1.gitStashTool, //
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
//
|
|
130
|
-
git_analytics_js_1.gitAnalyticsTool, // Analytics e
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
git_sync_js_1.gitSyncTool, // Sincronização multi-provider
|
|
134
|
-
git_repos_js_1.gitReposTool, // Gerenciamento de repositórios
|
|
135
|
-
git_config_js_1.gitConfigTool // Configurações avançadas
|
|
36
|
+
git_workflow_js_1.gitWorkflowTool, // 1. Workflow principal (init, commit, sync, status, backup)
|
|
37
|
+
git_files_js_1.gitFilesTool, // 2. Gerenciamento de arquivos
|
|
38
|
+
git_branches_js_1.gitBranchesTool, // 3. Gerenciamento de branches
|
|
39
|
+
git_issues_js_1.gitIssuesTool, // 4. Gerenciamento de issues
|
|
40
|
+
git_pulls_js_1.gitPullsTool, // 5. Gerenciamento de pull requests
|
|
41
|
+
git_tags_js_1.gitTagsTool, // 6. Gerenciamento de tags
|
|
42
|
+
git_release_js_1.gitReleaseTool, // 7. Gerenciamento de releases
|
|
43
|
+
git_remote_js_1.gitRemoteTool, // 8. Gerenciamento de remotes
|
|
44
|
+
git_reset_js_1.gitResetTool, // 9. Operações de reset
|
|
45
|
+
git_stash_js_1.gitStashTool, // 10. Gerenciamento de stash
|
|
46
|
+
git_config_js_1.gitConfigTool, // 11. Configurações Git
|
|
47
|
+
git_monitor_js_1.gitMonitorTool, // 12. Monitoramento e logs
|
|
48
|
+
git_backup_js_1.gitBackupTool, // 13. Sistema de backup
|
|
49
|
+
git_archive_js_1.gitArchiveTool, // 14. Arquivamento
|
|
50
|
+
git_packages_js_1.gitPackagesTool, // 15. Gerenciamento de packages
|
|
51
|
+
git_analytics_js_1.gitAnalyticsTool, // 16. Analytics e estatísticas
|
|
52
|
+
git_sync_js_1.gitSyncTool, // 17. Sincronização avançada
|
|
53
|
+
git_repos_js_1.gitReposTool // 18. Gerenciamento de repositórios
|
|
136
54
|
];
|
|
137
|
-
/**
|
|
138
|
-
* Recursos MCP disponíveis
|
|
139
|
-
*
|
|
140
|
-
* RESOURCES DISPONÍVEIS:
|
|
141
|
-
* - instructions: Instruções completas de uso de cada tool, action e parâmetro
|
|
142
|
-
* - examples: Exemplos práticos de uso das ferramentas
|
|
143
|
-
*/
|
|
144
55
|
const resources = [
|
|
145
56
|
{
|
|
146
|
-
uri: 'mcp-git://
|
|
147
|
-
name: '
|
|
148
|
-
description: '
|
|
57
|
+
uri: 'mcp-git://status',
|
|
58
|
+
name: 'Server Status',
|
|
59
|
+
description: 'Status atual do servidor MCP Git com todas as 18 tools',
|
|
149
60
|
mimeType: 'application/json'
|
|
150
61
|
},
|
|
151
62
|
{
|
|
152
|
-
uri: 'mcp-git://
|
|
153
|
-
name: '
|
|
154
|
-
description: '
|
|
63
|
+
uri: 'mcp-git://tools',
|
|
64
|
+
name: 'Available Tools',
|
|
65
|
+
description: 'Lista completa das 18 ferramentas Git disponíveis',
|
|
155
66
|
mimeType: 'application/json'
|
|
156
67
|
}
|
|
157
68
|
];
|
|
158
|
-
/**
|
|
159
|
-
* Servidor MCP principal para Gitea
|
|
160
|
-
*
|
|
161
|
-
* RESPONSABILIDADES:
|
|
162
|
-
* - Inicializar servidor MCP
|
|
163
|
-
* - Registrar handlers para requests
|
|
164
|
-
* - Gerenciar ciclo de vida das tools
|
|
165
|
-
* - Tratar erros e validações
|
|
166
|
-
*
|
|
167
|
-
* ARQUITETURA:
|
|
168
|
-
* - Server MCP padrão com transport stdio
|
|
169
|
-
* - Handlers para list e call de tools
|
|
170
|
-
* - Tratamento centralizado de erros
|
|
171
|
-
*
|
|
172
|
-
* RECOMENDAÇÕES:
|
|
173
|
-
* - Use apenas uma instância por processo
|
|
174
|
-
* - Configure handlers antes de conectar
|
|
175
|
-
* - Implemente graceful shutdown
|
|
176
|
-
*/
|
|
177
69
|
class GiteaMCPServer {
|
|
178
70
|
server;
|
|
179
71
|
constructor() {
|
|
180
72
|
this.server = new index_js_1.Server({
|
|
181
73
|
name: 'git-mcp',
|
|
182
|
-
version: '
|
|
74
|
+
version: '4.0.21',
|
|
75
|
+
}, {
|
|
76
|
+
capabilities: {
|
|
77
|
+
tools: {},
|
|
78
|
+
resources: {}
|
|
79
|
+
}
|
|
183
80
|
});
|
|
184
81
|
this.setupHandlers();
|
|
185
82
|
}
|
|
186
|
-
/**
|
|
187
|
-
* Configura os handlers para requests MCP
|
|
188
|
-
*
|
|
189
|
-
* HANDLERS IMPLEMENTADOS:
|
|
190
|
-
* - ListTools: Lista todas as tools disponíveis
|
|
191
|
-
* - CallTool: Executa uma tool específica
|
|
192
|
-
*
|
|
193
|
-
* FLUXO:
|
|
194
|
-
* 1. Validação de parâmetros
|
|
195
|
-
* 2. Busca da tool solicitada
|
|
196
|
-
* 3. Execução com tratamento de erros
|
|
197
|
-
* 4. Retorno de resultado ou erro
|
|
198
|
-
*
|
|
199
|
-
* TRATAMENTO DE ERROS:
|
|
200
|
-
* - Tool não encontrada: erro específico
|
|
201
|
-
* - Erro de execução: captura e formata
|
|
202
|
-
* - Erro de validação: mensagem descritiva
|
|
203
|
-
*/
|
|
204
83
|
setupHandlers() {
|
|
205
84
|
// Handler para listar tools disponíveis
|
|
206
85
|
this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
@@ -215,13 +94,11 @@ class GiteaMCPServer {
|
|
|
215
94
|
// Handler para executar tools específicas
|
|
216
95
|
this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
217
96
|
const { name, arguments: args } = request.params;
|
|
218
|
-
// Busca a tool solicitada
|
|
219
97
|
const tool = tools.find(t => t.name === name);
|
|
220
98
|
if (!tool) {
|
|
221
|
-
throw new Error(`Tool '${name}' not found`);
|
|
99
|
+
throw new Error(`Tool '${name}' not found. Available tools: ${tools.map(t => t.name).join(', ')}`);
|
|
222
100
|
}
|
|
223
101
|
try {
|
|
224
|
-
// Executa o handler da tool
|
|
225
102
|
const result = await tool.handler(args || {});
|
|
226
103
|
return {
|
|
227
104
|
content: [
|
|
@@ -234,8 +111,7 @@ class GiteaMCPServer {
|
|
|
234
111
|
}
|
|
235
112
|
catch (error) {
|
|
236
113
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
237
|
-
|
|
238
|
-
throw new Error(errorMessage);
|
|
114
|
+
throw new Error(`Error in ${name}: ${errorMessage}`);
|
|
239
115
|
}
|
|
240
116
|
});
|
|
241
117
|
// Handler para listar resources disponíveis
|
|
@@ -247,574 +123,137 @@ class GiteaMCPServer {
|
|
|
247
123
|
// Handler para ler conteúdo de resources específicos
|
|
248
124
|
this.server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) => {
|
|
249
125
|
const { uri } = request.params;
|
|
250
|
-
let content = '';
|
|
251
126
|
switch (uri) {
|
|
252
|
-
case 'mcp-git://
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
127
|
+
case 'mcp-git://status':
|
|
128
|
+
const cfg = config_js_1.config.getConfig();
|
|
129
|
+
const hasGitea = !!(cfg.giteaUrl && cfg.giteaToken);
|
|
130
|
+
const hasGitHub = !!cfg.githubToken;
|
|
131
|
+
const isDemoMode = process.env.DEMO_MODE === 'true';
|
|
132
|
+
const content = JSON.stringify({
|
|
133
|
+
title: 'MCP Git Server - Servidor Completo',
|
|
134
|
+
version: '4.0.21',
|
|
135
|
+
status: 'running',
|
|
136
|
+
timestamp: new Date().toISOString(),
|
|
137
|
+
mode: isDemoMode ? 'demo' : 'production',
|
|
138
|
+
providers: {
|
|
139
|
+
gitea: hasGitea ? 'configured' : 'not configured',
|
|
140
|
+
github: hasGitHub ? 'configured' : 'not configured',
|
|
141
|
+
demo: isDemoMode ? 'active' : 'inactive'
|
|
142
|
+
},
|
|
258
143
|
tools: {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
actions: {
|
|
262
|
-
init: {
|
|
263
|
-
description: 'Inicialização completa do projeto',
|
|
264
|
-
required: ['action', 'projectPath'],
|
|
265
|
-
optional: ['message'],
|
|
266
|
-
example: '{ "action": "init", "projectPath": "/path/to/project" }'
|
|
267
|
-
},
|
|
268
|
-
commit: {
|
|
269
|
-
description: 'Commit com push automático',
|
|
270
|
-
required: ['action', 'projectPath', 'message'],
|
|
271
|
-
optional: [],
|
|
272
|
-
example: '{ "action": "commit", "projectPath": "/path/to/project", "message": "feat: new feature" }'
|
|
273
|
-
},
|
|
274
|
-
sync: {
|
|
275
|
-
description: 'Sincronização completa (pull + commit + push)',
|
|
276
|
-
required: ['action', 'projectPath'],
|
|
277
|
-
optional: ['message'],
|
|
278
|
-
example: '{ "action": "sync", "projectPath": "/path/to/project" }'
|
|
279
|
-
},
|
|
280
|
-
status: {
|
|
281
|
-
description: 'Status completo do projeto',
|
|
282
|
-
required: ['action', 'projectPath'],
|
|
283
|
-
optional: ['detailed'],
|
|
284
|
-
example: '{ "action": "status", "projectPath": "/path/to/project", "detailed": true }'
|
|
285
|
-
},
|
|
286
|
-
backup: {
|
|
287
|
-
description: 'Backup completo do estado atual',
|
|
288
|
-
required: ['action', 'projectPath'],
|
|
289
|
-
optional: ['description'],
|
|
290
|
-
example: '{ "action": "backup", "projectPath": "/path/to/project", "description": "Backup antes de mudanças" }'
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
'git-files': {
|
|
295
|
-
description: 'Gerenciamento inteligente de arquivos',
|
|
296
|
-
actions: {
|
|
297
|
-
read: {
|
|
298
|
-
description: 'Ler conteúdo de arquivo',
|
|
299
|
-
required: ['action', 'projectPath', 'filePath'],
|
|
300
|
-
optional: [],
|
|
301
|
-
example: '{ "action": "read", "projectPath": "/path/to/project", "filePath": "src/index.ts" }'
|
|
302
|
-
},
|
|
303
|
-
write: {
|
|
304
|
-
description: 'Escrever arquivo com backup automático',
|
|
305
|
-
required: ['action', 'projectPath', 'filePath', 'content'],
|
|
306
|
-
optional: [],
|
|
307
|
-
example: '{ "action": "write", "projectPath": "/path/to/project", "filePath": "src/newfile.ts", "content": "export const hello = \'world\';" }'
|
|
308
|
-
},
|
|
309
|
-
search: {
|
|
310
|
-
description: 'Buscar texto no código',
|
|
311
|
-
required: ['action', 'projectPath', 'query'],
|
|
312
|
-
optional: ['path', 'caseSensitive'],
|
|
313
|
-
example: '{ "action": "search", "projectPath": "/path/to/project", "query": "function.*login" }'
|
|
314
|
-
},
|
|
315
|
-
update: {
|
|
316
|
-
description: 'Atualizar arquivo existente',
|
|
317
|
-
required: ['action', 'projectPath', 'filePath', 'content'],
|
|
318
|
-
optional: [],
|
|
319
|
-
example: '{ "action": "update", "projectPath": "/path/to/project", "filePath": "src/existing.ts", "content": "updated content" }'
|
|
320
|
-
},
|
|
321
|
-
'backup-files': {
|
|
322
|
-
description: 'Backup seletivo de arquivos',
|
|
323
|
-
required: ['action', 'projectPath'],
|
|
324
|
-
optional: ['patterns', 'description'],
|
|
325
|
-
example: '{ "action": "backup-files", "projectPath": "/path/to/project", "patterns": ["*.json", "*.config.*"] }'
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
'git-release': {
|
|
330
|
-
description: 'Sistema de release automatizado',
|
|
331
|
-
actions: {
|
|
332
|
-
create: {
|
|
333
|
-
description: 'Criar release com changelog automático',
|
|
334
|
-
required: ['action', 'projectPath'],
|
|
335
|
-
optional: ['version', 'changelog', 'draft', 'prerelease', 'assets', 'notes'],
|
|
336
|
-
example: '{ "action": "create", "projectPath": "/path/to/project", "changelog": true }'
|
|
337
|
-
},
|
|
338
|
-
version: {
|
|
339
|
-
description: 'Incrementar versão semântica',
|
|
340
|
-
required: ['action', 'projectPath'],
|
|
341
|
-
optional: ['type'],
|
|
342
|
-
example: '{ "action": "version", "projectPath": "/path/to/project", "type": "minor" }'
|
|
343
|
-
},
|
|
344
|
-
publish: {
|
|
345
|
-
description: 'Publicar release',
|
|
346
|
-
required: ['action', 'projectPath'],
|
|
347
|
-
optional: ['providers'],
|
|
348
|
-
example: '{ "action": "publish", "projectPath": "/path/to/project" }'
|
|
349
|
-
},
|
|
350
|
-
history: {
|
|
351
|
-
description: 'Histórico de releases',
|
|
352
|
-
required: ['action', 'projectPath'],
|
|
353
|
-
optional: ['limit', 'includeDrafts'],
|
|
354
|
-
example: '{ "action": "history", "projectPath": "/path/to/project", "limit": 10 }'
|
|
355
|
-
},
|
|
356
|
-
rollback: {
|
|
357
|
-
description: 'Rollback de release',
|
|
358
|
-
required: ['action', 'projectPath'],
|
|
359
|
-
optional: ['createBackup'],
|
|
360
|
-
example: '{ "action": "rollback", "projectPath": "/path/to/project", "createBackup": true }'
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
'git-monitor': {
|
|
365
|
-
description: 'Monitoramento e analytics',
|
|
366
|
-
actions: {
|
|
367
|
-
status: {
|
|
368
|
-
description: 'Status detalhado com métricas',
|
|
369
|
-
required: ['action', 'projectPath'],
|
|
370
|
-
optional: ['includeMetrics', 'detailed'],
|
|
371
|
-
example: '{ "action": "status", "projectPath": "/path/to/project", "includeMetrics": true }'
|
|
372
|
-
},
|
|
373
|
-
history: {
|
|
374
|
-
description: 'Histórico de atividades',
|
|
375
|
-
required: ['action', 'projectPath'],
|
|
376
|
-
optional: ['since', 'limit', 'type'],
|
|
377
|
-
example: '{ "action": "history", "projectPath": "/path/to/project", "since": "2024-01-01" }'
|
|
378
|
-
},
|
|
379
|
-
metrics: {
|
|
380
|
-
description: 'Métricas de produtividade',
|
|
381
|
-
required: ['action', 'projectPath'],
|
|
382
|
-
optional: ['period', 'includeCharts'],
|
|
383
|
-
example: '{ "action": "metrics", "projectPath": "/path/to/project", "period": "30d" }'
|
|
384
|
-
},
|
|
385
|
-
health: {
|
|
386
|
-
description: 'Análise de saúde do projeto',
|
|
387
|
-
required: ['action', 'projectPath'],
|
|
388
|
-
optional: ['deep', 'suggestions'],
|
|
389
|
-
example: '{ "action": "health", "projectPath": "/path/to/project", "deep": true }'
|
|
390
|
-
},
|
|
391
|
-
activity: {
|
|
392
|
-
description: 'Atividade recente',
|
|
393
|
-
required: ['action', 'projectPath'],
|
|
394
|
-
optional: ['hours', 'includeRemote'],
|
|
395
|
-
example: '{ "action": "activity", "projectPath": "/path/to/project", "hours": 24 }'
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
},
|
|
399
|
-
'git-backup': {
|
|
400
|
-
description: 'Sistema de backup inteligente',
|
|
401
|
-
actions: {
|
|
402
|
-
create: {
|
|
403
|
-
description: 'Criar backup',
|
|
404
|
-
required: ['action', 'projectPath'],
|
|
405
|
-
optional: ['type', 'name', 'includeUntracked', 'compress'],
|
|
406
|
-
example: '{ "action": "create", "projectPath": "/path/to/project", "type": "full" }'
|
|
407
|
-
},
|
|
408
|
-
restore: {
|
|
409
|
-
description: 'Restaurar backup',
|
|
410
|
-
required: ['action', 'projectPath', 'backupId'],
|
|
411
|
-
optional: ['preview', 'force', 'targetPath'],
|
|
412
|
-
example: '{ "action": "restore", "projectPath": "/path/to/project", "backupId": "backup-2024-01-01", "preview": true }'
|
|
413
|
-
},
|
|
414
|
-
list: {
|
|
415
|
-
description: 'Listar backups',
|
|
416
|
-
required: ['action', 'projectPath'],
|
|
417
|
-
optional: ['filter', 'limit', 'sortBy'],
|
|
418
|
-
example: '{ "action": "list", "projectPath": "/path/to/project", "filter": "full" }'
|
|
419
|
-
},
|
|
420
|
-
auto: {
|
|
421
|
-
description: 'Backup automático',
|
|
422
|
-
required: ['action', 'projectPath'],
|
|
423
|
-
optional: ['enabled', 'schedule', 'retention', 'maxBackups'],
|
|
424
|
-
example: '{ "action": "auto", "projectPath": "/path/to/project", "enabled": true, "schedule": "daily" }'
|
|
425
|
-
},
|
|
426
|
-
verify: {
|
|
427
|
-
description: 'Verificar integridade',
|
|
428
|
-
required: ['action', 'projectPath', 'backupId'],
|
|
429
|
-
optional: ['deep'],
|
|
430
|
-
example: '{ "action": "verify", "projectPath": "/path/to/project", "backupId": "backup-2024-01-01" }'
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
},
|
|
434
|
-
'git-branches': {
|
|
435
|
-
description: 'Gerenciamento de branches',
|
|
436
|
-
actions: {
|
|
437
|
-
create: {
|
|
438
|
-
description: 'Criar nova branch',
|
|
439
|
-
required: ['action', 'projectPath', 'name'],
|
|
440
|
-
optional: ['from'],
|
|
441
|
-
example: '{ "action": "create", "projectPath": "/path/to/project", "name": "feature/new-feature" }'
|
|
442
|
-
},
|
|
443
|
-
list: {
|
|
444
|
-
description: 'Listar branches',
|
|
445
|
-
required: ['action', 'projectPath'],
|
|
446
|
-
optional: ['remote'],
|
|
447
|
-
example: '{ "action": "list", "projectPath": "/path/to/project", "remote": true }'
|
|
448
|
-
},
|
|
449
|
-
switch: {
|
|
450
|
-
description: 'Trocar de branch',
|
|
451
|
-
required: ['action', 'projectPath', 'name'],
|
|
452
|
-
optional: ['create'],
|
|
453
|
-
example: '{ "action": "switch", "projectPath": "/path/to/project", "name": "main" }'
|
|
454
|
-
},
|
|
455
|
-
delete: {
|
|
456
|
-
description: 'Remover branch',
|
|
457
|
-
required: ['action', 'projectPath', 'name'],
|
|
458
|
-
optional: ['force'],
|
|
459
|
-
example: '{ "action": "delete", "projectPath": "/path/to/project", "name": "old-branch" }'
|
|
460
|
-
},
|
|
461
|
-
merge: {
|
|
462
|
-
description: 'Merge de branches',
|
|
463
|
-
required: ['action', 'projectPath', 'branch'],
|
|
464
|
-
optional: ['strategy', 'noCommit'],
|
|
465
|
-
example: '{ "action": "merge", "projectPath": "/path/to/project", "branch": "feature/complete", "strategy": "squash" }'
|
|
466
|
-
},
|
|
467
|
-
compare: {
|
|
468
|
-
description: 'Comparar branches',
|
|
469
|
-
required: ['action', 'projectPath', 'base', 'head'],
|
|
470
|
-
optional: ['detailed'],
|
|
471
|
-
example: '{ "action": "compare", "projectPath": "/path/to/project", "base": "main", "head": "feature/new" }'
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
}
|
|
144
|
+
total: tools.length,
|
|
145
|
+
available: tools.map(t => t.name)
|
|
475
146
|
},
|
|
476
|
-
|
|
477
|
-
'
|
|
478
|
-
'
|
|
479
|
-
'
|
|
480
|
-
'
|
|
481
|
-
|
|
147
|
+
features: [
|
|
148
|
+
'Auto-detecção universal',
|
|
149
|
+
'Multi-provider (Gitea + GitHub)',
|
|
150
|
+
'Interface universal para IA',
|
|
151
|
+
'Error handling inteligente',
|
|
152
|
+
'18 ferramentas Git completas'
|
|
153
|
+
]
|
|
482
154
|
}, null, 2);
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
workflows: {
|
|
490
|
-
'daily-workflow': {
|
|
491
|
-
description: 'Workflow diário de desenvolvimento',
|
|
492
|
-
steps: [
|
|
493
|
-
{
|
|
494
|
-
description: 'Sincronizar com mudanças do time',
|
|
495
|
-
tool: 'git-workflow',
|
|
496
|
-
action: 'sync',
|
|
497
|
-
params: { action: 'sync', projectPath: '/path/to/project' }
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
description: 'Ver status do projeto',
|
|
501
|
-
tool: 'git-workflow',
|
|
502
|
-
action: 'status',
|
|
503
|
-
params: { action: 'status', projectPath: '/path/to/project', detailed: true }
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
description: 'Implementar nova funcionalidade',
|
|
507
|
-
tool: 'git-files',
|
|
508
|
-
action: 'write',
|
|
509
|
-
params: {
|
|
510
|
-
action: 'write',
|
|
511
|
-
projectPath: '/path/to/project',
|
|
512
|
-
filePath: 'src/new-feature.ts',
|
|
513
|
-
content: 'export function newFeature() { return "Hello World"; }'
|
|
514
|
-
}
|
|
515
|
-
},
|
|
516
|
-
{
|
|
517
|
-
description: 'Commit das mudanças',
|
|
518
|
-
tool: 'git-workflow',
|
|
519
|
-
action: 'commit',
|
|
520
|
-
params: {
|
|
521
|
-
action: 'commit',
|
|
522
|
-
projectPath: '/path/to/project',
|
|
523
|
-
message: 'feat: Implementar nova funcionalidade\n\n- Adicionar função newFeature\n- Export da função\n- Documentação básica'
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
]
|
|
527
|
-
},
|
|
528
|
-
'feature-development': {
|
|
529
|
-
description: 'Desenvolvimento completo de uma feature',
|
|
530
|
-
steps: [
|
|
531
|
-
{
|
|
532
|
-
description: 'Criar branch da feature',
|
|
533
|
-
tool: 'git-branches',
|
|
534
|
-
action: 'create',
|
|
535
|
-
params: { action: 'create', projectPath: '/path/to/project', name: 'feature/user-auth' }
|
|
536
|
-
},
|
|
537
|
-
{
|
|
538
|
-
description: 'Implementar autenticação',
|
|
539
|
-
tool: 'git-files',
|
|
540
|
-
action: 'write',
|
|
541
|
-
params: {
|
|
542
|
-
action: 'write',
|
|
543
|
-
projectPath: '/path/to/project',
|
|
544
|
-
filePath: 'src/auth/login.ts',
|
|
545
|
-
content: 'export function login(email: string, password: string) { /* auth logic */ }'
|
|
546
|
-
}
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
description: 'Verificar TODOs/FIXMEs',
|
|
550
|
-
tool: 'git-issues',
|
|
551
|
-
action: 'scan',
|
|
552
|
-
params: { action: 'scan', projectPath: '/path/to/project', createIssues: true }
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
description: 'Commit da implementação',
|
|
556
|
-
tool: 'git-workflow',
|
|
557
|
-
action: 'commit',
|
|
558
|
-
params: {
|
|
559
|
-
action: 'commit',
|
|
560
|
-
projectPath: '/path/to/project',
|
|
561
|
-
message: 'feat: Implementar sistema de autenticação\n\n- Função login\n- Validação de credenciais\n- Tratamento de erros'
|
|
562
|
-
}
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
description: 'Merge na branch principal',
|
|
566
|
-
tool: 'git-branches',
|
|
567
|
-
action: 'merge',
|
|
568
|
-
params: { action: 'merge', projectPath: '/path/to/project', branch: 'feature/user-auth' }
|
|
569
|
-
}
|
|
570
|
-
]
|
|
571
|
-
},
|
|
572
|
-
'release-process': {
|
|
573
|
-
description: 'Processo completo de release',
|
|
574
|
-
steps: [
|
|
575
|
-
{
|
|
576
|
-
description: 'Verificar saúde pré-release',
|
|
577
|
-
tool: 'git-monitor',
|
|
578
|
-
action: 'health',
|
|
579
|
-
params: { action: 'health', projectPath: '/path/to/project', deep: true }
|
|
580
|
-
},
|
|
581
|
-
{
|
|
582
|
-
description: 'Criar backup estratégico',
|
|
583
|
-
tool: 'git-workflow',
|
|
584
|
-
action: 'backup',
|
|
585
|
-
params: { action: 'backup', projectPath: '/path/to/project', description: 'Backup pré-release v2.0.0' }
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
description: 'Incrementar versão',
|
|
589
|
-
tool: 'git-release',
|
|
590
|
-
action: 'version',
|
|
591
|
-
params: { action: 'version', projectPath: '/path/to/project', type: 'minor' }
|
|
592
|
-
},
|
|
593
|
-
{
|
|
594
|
-
description: 'Criar release completo',
|
|
595
|
-
tool: 'git-release',
|
|
596
|
-
action: 'create',
|
|
597
|
-
params: {
|
|
598
|
-
action: 'create',
|
|
599
|
-
projectPath: '/path/to/project',
|
|
600
|
-
changelog: true,
|
|
601
|
-
notes: 'Release v2.0.0 com novas funcionalidades',
|
|
602
|
-
assets: ['dist/bundle.js', 'dist/styles.css']
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
]
|
|
155
|
+
return {
|
|
156
|
+
contents: [
|
|
157
|
+
{
|
|
158
|
+
uri,
|
|
159
|
+
mimeType: 'application/json',
|
|
160
|
+
text: content
|
|
606
161
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
description: 'Commit diário das mudanças',
|
|
624
|
-
example: {
|
|
625
|
-
tool: 'git-workflow',
|
|
626
|
-
action: 'commit',
|
|
627
|
-
params: {
|
|
628
|
-
action: 'commit',
|
|
629
|
-
projectPath: 'C:\\projetos\\api-backend',
|
|
630
|
-
message: 'feat: Implementar autenticação JWT\n\n- Middleware de validação de tokens\n- Endpoint POST /auth/login\n- Endpoint POST /auth/refresh\n- Tests unitários para auth\n- Documentação da API'
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
},
|
|
634
|
-
'backup-before-changes': {
|
|
635
|
-
description: 'Backup antes de mudanças arriscadas',
|
|
636
|
-
example: {
|
|
637
|
-
tool: 'git-workflow',
|
|
638
|
-
action: 'backup',
|
|
639
|
-
params: {
|
|
640
|
-
action: 'backup',
|
|
641
|
-
projectPath: 'C:\\projetos\\critical-app',
|
|
642
|
-
description: 'Backup antes de refatoração da arquitetura principal'
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
},
|
|
646
|
-
'search-code': {
|
|
647
|
-
description: 'Buscar funções específicas no código',
|
|
648
|
-
example: {
|
|
649
|
-
tool: 'git-files',
|
|
650
|
-
action: 'search',
|
|
651
|
-
params: {
|
|
652
|
-
action: 'search',
|
|
653
|
-
projectPath: 'C:\\projetos\\large-app',
|
|
654
|
-
query: 'function.*validate.*email|const.*emailRegex',
|
|
655
|
-
caseSensitive: false
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
},
|
|
659
|
-
'health-check': {
|
|
660
|
-
description: 'Verificar saúde do projeto',
|
|
661
|
-
example: {
|
|
662
|
-
tool: 'git-monitor',
|
|
663
|
-
action: 'health',
|
|
664
|
-
params: {
|
|
665
|
-
action: 'health',
|
|
666
|
-
projectPath: 'C:\\projetos\\my-project',
|
|
667
|
-
deep: true,
|
|
668
|
-
suggestions: true
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
},
|
|
672
|
-
'feature-branch-workflow': {
|
|
673
|
-
description: 'Workflow completo com feature branch',
|
|
674
|
-
steps: [
|
|
675
|
-
{ tool: 'git-branches', action: 'create', params: { action: 'create', projectPath: '/project', name: 'feature/new-ui' } },
|
|
676
|
-
{ tool: 'git-files', action: 'write', params: { action: 'write', projectPath: '/project', filePath: 'src/ui/new-component.tsx', content: '...' } },
|
|
677
|
-
{ tool: 'git-workflow', action: 'commit', params: { action: 'commit', projectPath: '/project', message: 'feat: New UI component' } },
|
|
678
|
-
{ tool: 'git-branches', action: 'merge', params: { action: 'merge', projectPath: '/project', branch: 'feature/new-ui' } },
|
|
679
|
-
{ tool: 'git-branches', action: 'delete', params: { action: 'delete', projectPath: '/project', name: 'feature/new-ui' } }
|
|
680
|
-
]
|
|
162
|
+
]
|
|
163
|
+
};
|
|
164
|
+
case 'mcp-git://tools':
|
|
165
|
+
const toolsInfo = JSON.stringify({
|
|
166
|
+
title: 'Ferramentas Git Disponíveis',
|
|
167
|
+
total: tools.length,
|
|
168
|
+
tools: tools.map(tool => ({
|
|
169
|
+
name: tool.name,
|
|
170
|
+
description: tool.description,
|
|
171
|
+
category: this.getToolCategory(tool.name)
|
|
172
|
+
})),
|
|
173
|
+
usage: {
|
|
174
|
+
pattern: 'Universal: action + projectPath',
|
|
175
|
+
example: {
|
|
176
|
+
action: 'status',
|
|
177
|
+
projectPath: '/path/to/project'
|
|
681
178
|
}
|
|
682
179
|
}
|
|
683
180
|
}, null, 2);
|
|
684
|
-
|
|
181
|
+
return {
|
|
182
|
+
contents: [
|
|
183
|
+
{
|
|
184
|
+
uri,
|
|
185
|
+
mimeType: 'application/json',
|
|
186
|
+
text: toolsInfo
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
};
|
|
685
190
|
default:
|
|
686
|
-
throw new Error(`Resource
|
|
191
|
+
throw new Error(`Resource '${uri}' not found`);
|
|
687
192
|
}
|
|
688
|
-
return {
|
|
689
|
-
contents: [
|
|
690
|
-
{
|
|
691
|
-
uri: uri,
|
|
692
|
-
mimeType: 'application/json',
|
|
693
|
-
text: content
|
|
694
|
-
}
|
|
695
|
-
]
|
|
696
|
-
};
|
|
697
193
|
});
|
|
698
194
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
195
|
+
getToolCategory(toolName) {
|
|
196
|
+
const categories = {
|
|
197
|
+
'git-workflow': 'Workflow Principal',
|
|
198
|
+
'git-files': 'Gerenciamento de Arquivos',
|
|
199
|
+
'git-branches': 'Branches',
|
|
200
|
+
'git-issues': 'Issues',
|
|
201
|
+
'git-pulls': 'Pull Requests',
|
|
202
|
+
'git-tags': 'Tags',
|
|
203
|
+
'git-release': 'Releases',
|
|
204
|
+
'git-remote': 'Remotes',
|
|
205
|
+
'git-reset': 'Reset',
|
|
206
|
+
'git-stash': 'Stash',
|
|
207
|
+
'git-config': 'Configuração',
|
|
208
|
+
'git-monitor': 'Monitoramento',
|
|
209
|
+
'git-backup': 'Backup',
|
|
210
|
+
'git-archive': 'Arquivamento',
|
|
211
|
+
'git-packages': 'Packages',
|
|
212
|
+
'git-analytics': 'Analytics',
|
|
213
|
+
'git-sync': 'Sincronização',
|
|
214
|
+
'git-repos': 'Repositórios'
|
|
215
|
+
};
|
|
216
|
+
return categories[toolName] || 'Geral';
|
|
217
|
+
}
|
|
718
218
|
async run() {
|
|
719
219
|
const cfg = config_js_1.config.getConfig();
|
|
720
|
-
|
|
721
|
-
|
|
220
|
+
// Ativar modo demo automaticamente se não há configuração
|
|
221
|
+
if (!cfg.giteaUrl && !cfg.githubToken && !cfg.apiUrl) {
|
|
222
|
+
process.env.DEMO_MODE = 'true';
|
|
223
|
+
console.error('[SERVER] No provider configuration found. Enabling demo mode automatically.');
|
|
722
224
|
}
|
|
723
|
-
// Inicializar provider factory
|
|
225
|
+
// Inicializar provider factory
|
|
724
226
|
try {
|
|
725
|
-
// console.log('[SERVER] Inicializando provider factory...');
|
|
726
227
|
const factory = (0, index_js_2.initializeFactoryFromEnv)();
|
|
727
|
-
// Log detalhado dos providers configurados
|
|
728
|
-
try {
|
|
729
|
-
const providersInfo = factory.getProvidersInfo();
|
|
730
|
-
// console.log('[SERVER] Providers configurados:');
|
|
731
|
-
// providersInfo.forEach(p => {
|
|
732
|
-
// console.log(` - ${p.name} (${p.type}) ${p.isDefault ? '[PADRÃO]' : ''}`);
|
|
733
|
-
// });
|
|
734
|
-
}
|
|
735
|
-
catch (infoError) {
|
|
736
|
-
// console.log('[SERVER] Não foi possível obter informações detalhadas dos providers');
|
|
737
|
-
}
|
|
738
|
-
// Atualizar o globalProviderFactory com a configuração
|
|
739
228
|
Object.assign(index_js_2.globalProviderFactory, factory);
|
|
740
|
-
|
|
229
|
+
console.error('[SERVER] Provider factory initialized successfully');
|
|
741
230
|
}
|
|
742
231
|
catch (error) {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
try {
|
|
746
|
-
// console.log('[SERVER] Tentando criar provider fallback...');
|
|
747
|
-
// Criar provider GitHub básico como fallback
|
|
748
|
-
const fallbackConfig = {
|
|
749
|
-
name: 'github-fallback',
|
|
750
|
-
type: 'github',
|
|
751
|
-
apiUrl: 'https://api.github.com',
|
|
752
|
-
baseUrl: 'https://github.com',
|
|
753
|
-
token: process.env.GITHUB_TOKEN || 'dummy_token',
|
|
754
|
-
username: process.env.GITHUB_USERNAME
|
|
755
|
-
};
|
|
756
|
-
const fallbackProvider = index_js_2.globalProviderFactory.createProvider(fallbackConfig);
|
|
757
|
-
index_js_2.globalProviderFactory.setDefaultProvider('github-fallback');
|
|
758
|
-
// console.log('[SERVER] Provider fallback criado com sucesso');
|
|
759
|
-
}
|
|
760
|
-
catch (fallbackError) {
|
|
761
|
-
console.error('[SERVER] Falha ao criar provider fallback:', fallbackError);
|
|
762
|
-
// Continua sem provider - algumas tools podem não funcionar
|
|
763
|
-
}
|
|
232
|
+
process.env.DEMO_MODE = 'true';
|
|
233
|
+
console.error('[SERVER] Provider initialization failed, using demo mode');
|
|
764
234
|
}
|
|
765
235
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
766
236
|
await this.server.connect(transport);
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
}
|
|
237
|
+
// Log de inicialização
|
|
238
|
+
console.error(`[SERVER] MCP Git server v4.0.21 started successfully`);
|
|
239
|
+
console.error(`[SERVER] Mode: ${process.env.DEMO_MODE === 'true' ? 'Demo' : 'Production'}`);
|
|
240
|
+
console.error(`[SERVER] Tools available: ${tools.length}`);
|
|
241
|
+
console.error(`[SERVER] Ready for AI agent integration`);
|
|
770
242
|
}
|
|
771
|
-
/**
|
|
772
|
-
* Fecha o servidor MCP graciosamente
|
|
773
|
-
*
|
|
774
|
-
* USO:
|
|
775
|
-
* - Durante shutdown da aplicação
|
|
776
|
-
* - Para limpeza de recursos
|
|
777
|
-
* - Para finalização controlada
|
|
778
|
-
*
|
|
779
|
-
* RECOMENDAÇÕES:
|
|
780
|
-
* - Sempre chame antes de sair
|
|
781
|
-
* - Aguarde a conclusão da operação
|
|
782
|
-
* - Trate erros de fechamento
|
|
783
|
-
*/
|
|
784
243
|
async close() {
|
|
785
244
|
await this.server.close();
|
|
786
245
|
}
|
|
787
246
|
}
|
|
788
247
|
exports.GiteaMCPServer = GiteaMCPServer;
|
|
789
|
-
|
|
790
|
-
* Handlers para sinais do sistema
|
|
791
|
-
*
|
|
792
|
-
* SINAIS TRATADOS:
|
|
793
|
-
* - SIGINT: Interrupção do usuário (Ctrl+C)
|
|
794
|
-
* - unhandledRejection: Promises rejeitadas
|
|
795
|
-
* - uncaughtException: Exceções não tratadas
|
|
796
|
-
*
|
|
797
|
-
* COMPORTAMENTO:
|
|
798
|
-
* - SIGINT: Shutdown gracioso
|
|
799
|
-
* - Erros não tratados: Exit com código 1
|
|
800
|
-
* - Log de erro antes de sair
|
|
801
|
-
*
|
|
802
|
-
* RECOMENDAÇÕES:
|
|
803
|
-
* - Implemente graceful shutdown
|
|
804
|
-
* - Log todos os erros fatais
|
|
805
|
-
* - Use códigos de saída apropriados
|
|
806
|
-
*/
|
|
807
|
-
// Handler para interrupção do usuário (Ctrl+C)
|
|
248
|
+
// Handlers para sinais do sistema
|
|
808
249
|
process.on('SIGINT', async () => {
|
|
809
|
-
|
|
250
|
+
console.error('[SERVER] Shutting down gracefully...');
|
|
810
251
|
process.exit(0);
|
|
811
252
|
});
|
|
812
|
-
// Handler para promises rejeitadas não tratadas
|
|
813
253
|
process.on('unhandledRejection', (reason, promise) => {
|
|
814
254
|
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
|
815
255
|
process.exit(1);
|
|
816
256
|
});
|
|
817
|
-
// Handler para exceções não tratadas
|
|
818
257
|
process.on('uncaughtException', (error) => {
|
|
819
258
|
console.error('Uncaught Exception:', error);
|
|
820
259
|
process.exit(1);
|