forked from IBM/mcp-context-forge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
534 lines (473 loc) Β· 21.2 KB
/
.pre-commit-config.yaml
File metadata and controls
534 lines (473 loc) Β· 21.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
# -----------------------------------------------------------------------------
# π οΈ Pre-commit Configuration
# -----------------------------------------------------------------------------
# This configuration file sets up various pre-commit hooks to enforce code quality,
# security, and formatting standards before commits are made.
#
# Installation:
# pip install --user --upgrade pre-commit
# pre-commit install
# pre-commit run --all-files
# Update:
# pre-commit autoupdate
#
# To skip pre-commit checks:
# git commit -m "Your message" --no-verify
#
# NOTE: Some hooks modify files automatically (formatters), while others only
# report issues (linters). Modified files will need to be staged again.
# -----------------------------------------------------------------------------
exclude: '(^|/)(\.pre-commit-.*\.yaml|normalize_special_characters\.py|test_input_validation\.py|ai_artifacts_normalizer\.py)$|(^|/)mcp-servers/templates/|(^|/)tests/load/|.*\.(jinja|j2)$' # ignore these files, all templates, load tests, and jinja files
repos:
# -----------------------------------------------------------------------------
# π Security and Secret Detection Hooks
# -----------------------------------------------------------------------------
- repo: https://github.com/gitleaks/gitleaks
rev: v8.27.2
hooks:
- id: gitleaks
name: π Gitleaks - Detect hardcoded secrets
description: Scans for hardcoded secrets like API keys and passwords.
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# - id: detect-aws-credentials
# name: π Detect AWS Credentials
# description: Detects *your* aws credentials from the aws cli credentials file.
# types: [text]
- id: detect-private-key
name: π Detect Private Key
description: Detects the presence of private keys.
types: [text]
# - repo: https://github.com/Yelp/detect-secrets
# rev: v1.5.0
# hooks:
# - id: detect-secrets
# name: π Detect Secrets
# description: Detects secrets within a repository.
# args: ['--baseline', '.secrets.baseline']
# -----------------------------------------------------------------------------
# β Forbid Specific AI / LLM Patterns
# -----------------------------------------------------------------------------
# Local hooks that block the most common "AI artefacts" before they enter
# the repository - including:
#
# - `:contentReference`
# - `[oaicite:??<digits>]` or filecite (e.g. `[oaicite:??12345]`)
# - source=chatgpt.com
# - Stock phrases such as
# - "As an AI language model"
# - "I am an AI developed by"
# - "This response was generated by"
# - "In conclusion," / "To summarize," / "It is important to note that"
# - "Remember that" / "Keep in mind that"
# - Placeholder citations like `(Author, 2023)` and `(Source: ...)`
# - Any code-fence of **four or more** consecutive back-ticks: ```` , ``````, ...
# -----------------------------------------------------------------------------
- repo: local
hooks:
- id: forbid-content-reference
name: β Forbid :contentReference
description: Prevents :contentReference patterns from being committed.
entry: ':contentReference'
language: pygrep
types: [text]
exclude: ^\.pre-commit-config\.yaml$
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
- id: forbid-oai-citations
name: β Forbid OpenAI Citations
description: Prevents [oaicite:??digits] patterns from being committed.
entry: '\[oaicite:\?\?\d+\]'
language: pygrep
types: [text]
exclude: ^\.pre-commit-config\.yaml$
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
- id: forbid-ai-stock-phrases
name: β Forbid AI Stock Phrases
description: Prevents common AI-generated phrases from being committed.
entry: '(?i)(brevity|source=chatgpt.com|turn0search0|filecite|as an ai language model|i am an ai developed by|this response was generated by|i don''t have real-time information|i don''t have access to real-time|i can''t browse the internet|i cannot browse the internet|my knowledge cutoff|my training data|i''m not able to access|i don''t have the ability to)'
language: pygrep
types: [text]
exclude: ^\.pre-commit-config\.yaml$
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
- id: forbid-placeholder-citations
name: β Forbid Placeholder Citations
description: Prevents placeholder citations like (Author, 2023) from being committed.
entry: '\([A-Z][a-z]+,?\s+\d{4}\)'
language: pygrep
types: [text]
exclude: ^\.pre-commit-config\.yaml$
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
- id: forbid-source-placeholders
name: β Forbid Source Placeholders
description: Prevents (Source:...) placeholders from being committed.
entry: '(?i)\(source:'
language: pygrep
types: [text]
exclude: ^\.pre-commit-config\.yaml$
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
- id: forbid-malformed-code-fences
name: β Forbid Malformed Code Fences
description: Prevents code fences with 4+ backticks from being committed.
entry: '````+'
language: pygrep
types: [text]
exclude: ^\.pre-commit-config\.yaml$
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
- id: warn-ai-transitions
name: β οΈ Warn AI Transition Phrases
description: Warns about common AI transition phrases (non-blocking).
entry: '(?i)(brevity|in conclusion,|to summarize,|it is important to note that|remember that|keep in mind that|it''s worth noting that|please note that)'
language: pygrep
types: [text]
verbose: true
exclude: ^\.pre-commit-config\.yaml$
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
# -----------------------------------------------------------------------------
# π€ Unicode Text Normalization (via texthooks)
# -----------------------------------------------------------------------------
# A collection of hooks to clean up problematic Unicode characters:
#
# π fix-smartquotes: Converts curly quotes (" " ' ') to standard ASCII quotes.
# π‘ fix-ligatures: Replaces typographic ligatures (fi, ff) with ASCII equivalents.
# β£ fix-spaces: Normalizes non-breaking and exotic spaces to regular spaces.
# π« forbid-bidi-controls: Prevents Unicode BiDi control characters used to
# obscure code logic or directionality.
#
# These prevent copy-paste artifacts, invisible formatting errors, and
# encoding bugs from creeping into the codebase.
# -----------------------------------------------------------------------------
- repo: https://github.com/sirosen/texthooks
rev: 0.6.8
hooks:
- id: fix-smartquotes
name: π Normalize Smart Quotes
description: Replaces smart/curly quotes with standard ASCII quotes.
- id: fix-ligatures
name: π‘ Normalize Ligatures
description: Replaces typographic ligatures with standard characters.
- id: fix-spaces
name: β£ Normalize Unicode Spaces
description: Replaces non-breaking or exotic space characters with regular spaces.
- id: forbid-bidi-controls
name: π« Forbid BiDi Unicode Controls
description: Prevents bidirectional control characters that can obscure code meaning.
# -----------------------------------------------------------------------------
# π§Ή Formatting Hooks (MODIFIES FILES)
# -----------------------------------------------------------------------------
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: end-of-file-fixer
name: π§Ή Fix End of Files
description: Ensures that a file is either empty, or ends with one newline.
types: [text]
stages: [pre-commit, pre-push, manual]
- id: trailing-whitespace
name: π§Ή Trim Trailing Whitespace
description: Trims trailing whitespace.
types: [text]
stages: [pre-commit, pre-push, manual]
- id: fix-byte-order-marker
name: π§Ή Fix UTF-8 Byte Order Marker
description: Removes UTF-8 byte order marker.
types: [text]
- id: mixed-line-ending
name: π§Ή Mixed Line Ending
description: Replaces or checks mixed line ending.
types: [text, python]
args: [--fix=lf]
- id: requirements-txt-fixer
name: π§Ή Fix requirements.txt
description: Sorts entries in requirements.txt.
files: (requirements|constraints).*\.txt$
- id: file-contents-sorter
name: π§Ή File Contents Sorter
description: Sorts the lines in specified files (defaults to alphabetical).
language: python
files: "^$"
- id: sort-simple-yaml
name: π§Ή Sort Simple YAML Files
description: Sorts simple YAML files which consist only of top-level keys.
files: "^$"
# Optional: Uncomment to enable Prettier formatting
# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: v3.0.3
# hooks:
# - id: prettier
# name: π§Ή Prettier - Code Formatter
# description: Formats JavaScript, TypeScript, CSS, HTML, JSON, Markdown, and more.
# types_or: [javascript, jsx, ts, tsx, css, less, scss, json, markdown, yaml]
# -----------------------------------------------------------------------------
# β
Code Quality and Validation Hooks (LINTING ONLY)
# -----------------------------------------------------------------------------
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
name: β
Check Added Large Files
description: Prevents committing large files.
stages: [pre-commit, pre-push, manual]
- id: check-case-conflict
name: β
Check Case Conflicts
description: Checks for files that would conflict in case-insensitive filesystems.
- id: check-merge-conflict
name: β
Check Merge Conflicts
description: Checks for files that contain merge conflict strings.
types: [text]
- id: check-symlinks
name: β
Check Symlinks
description: Checks for symlinks which do not point to anything.
types: [symlink]
- id: destroyed-symlinks
name: β
Detect Destroyed Symlinks
description: Detects symlinks which are changed to regular files.
types: [file]
- id: check-executables-have-shebangs
name: β
Check Executables Have Shebangs
description: Ensures that (non-binary) executables have a shebang.
types: [text, executable]
stages: [pre-commit, pre-push, manual]
- id: check-shebang-scripts-are-executable
name: β
Check Shebang Scripts Are Executable
description: Ensures that (non-binary) files with a shebang are executable.
types: [text]
stages: [pre-commit, pre-push, manual]
- id: forbid-new-submodules
name: β
Forbid New Submodules
description: Prevents addition of new git submodules.
types: [directory]
- id: forbid-submodules
name: β
Forbid Submodules
description: Forbids any submodules in the repository.
language: fail
entry: "submodules are not allowed in this repository:"
types: [directory]
- id: check-vcs-permalinks
name: β
Check VCS Permalinks
description: Ensures that links to VCS websites are permalinks.
types: [text]
# File Format Validation
- id: check-json
name: β
Check JSON
description: Checks JSON files for parseable syntax.
types: [json]
- id: check-yaml
name: β
Check YAML
description: Checks YAML files for parseable syntax.
types: [yaml]
exclude: ^(docs/|charts/)
- id: check-toml
name: β
Check TOML
description: Checks TOML files for parseable syntax.
types: [toml]
- id: check-xml
name: β
Check XML
description: Checks XML files for parseable syntax.
types: [xml]
- id: check-byte-order-marker
name: β
Check Byte Order Marker
description: Forbids files which have a UTF-8 byte-order marker.
types: [text]
- repo: https://github.com/adrienverge/yamllint
rev: v1.37.1
hooks:
- id: yamllint
name: β
YAMLlint - YAML Linter
description: A linter for YAML files.
args: [-c, .yamllint]
# Lint *.yml|*.yaml everywhere EXCEPT charts/**
files: ^.*\.(yml|yaml)$
exclude: ^charts/
# - repo: https://github.com/igorshubovych/markdownlint-cli
# rev: v0.45.0
# hooks:
# - id: markdownlint
# name: β
Markdownlint - Markdown Linter
# description: A tool to check markdown files and flag style issues.
# -----------------------------------------------------------------------------
# π Python Code Quality Hooks (LINTING ONLY)
# -----------------------------------------------------------------------------
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-ast
name: π Check Python AST
description: Simply checks whether the files parse as valid python.
language: python
types: [python]
exclude: ^templates/
- id: check-builtin-literals
name: π Check Builtin Literals
description: Requires literal syntax when initializing empty or zero Python builtin types.
language: python
types: [python]
exclude: ^templates/
- id: check-docstring-first
name: π Check Docstring is First
description: Checks a common error of defining a docstring after code.
language: python
types: [python]
- id: debug-statements
name: π Debug Statements (Python)
description: Checks for debugger imports and py37+ `breakpoint()` calls.
types: [python]
language: python
exclude: ^templates/
- id: name-tests-test
name: π Python Tests Naming
description: Verifies test files in tests/ directories start with `test_`.
language: python
files: (^|/)tests/.+\.py$
exclude: ^tests/(.*/)?(pages|helpers|fuzzers|scripts|fixtures|migration|utils|manual|async|load)/.*\.py$
args: [--pytest-test-first] # `test_.*\.py`
- repo: https://github.com/pycqa/flake8
rev: 7.2.0
hooks:
- id: flake8
name: π Flake8 - Python Linter
description: Tool for style guide enforcement.
# - repo: https://github.com/pycqa/bandit
# rev: 1.8.3
# hooks:
# - id: bandit
# name: π Bandit - Security Linter
# description: A tool designed to find common security issues in Python code.
# args: [--skip, "B101,B601"]
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.16.0
# hooks:
# - id: mypy
# name: π MyPy - Static Type Checker
# description: Optional static typing for Python.
# additional_dependencies: [types-all]
# - repo: https://github.com/pycqa/pydocstyle
# rev: 6.3.0
# hooks:
# - id: pydocstyle
# name: π PyDocStyle - Docstring Checker
# description: A static analysis tool for checking compliance with Python docstring conventions.
# -----------------------------------------------------------------------------
# π Python Formatting Hooks (MODIFIES FILES)
# -----------------------------------------------------------------------------
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.11.12
hooks:
# Run the linter.
- id: ruff-check
types_or: [ python, pyi ]
args: [ --fix ]
files: ^mcpgateway/
# Run the formatter.
# - id: ruff-format
# types_or: [ python, pyi ]
# files: ^mcpgateway/
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
name: π Black - Python Code Formatter
description: The uncompromising Python code formatter.
language_version: python3
# - repo: https://github.com/pycqa/isort
# rev: 6.0.1
# hooks:
# - id: isort
# name: π isort - Import Sorter
# description: A Python utility / library to sort imports.
# args: [--profile=black]
# - repo: https://github.com/asottile/pyupgrade
# rev: v3.20.0
# hooks:
# - id: pyupgrade
# name: π PyUpgrade - Python Syntax Upgrader
# description: Automatically upgrade syntax for newer versions of the language.
# args: [--py38-plus]
# Optional: Uncomment to enforce single quotes in Python
# - repo: https://github.com/pre-commit/pre-commit-hooks
# rev: v5.0.0
# hooks:
# - id: double-quote-string-fixer
# name: π Fix Double Quoted Strings
# description: Replaces double quoted strings with single quoted strings.
# types: [python]
# -----------------------------------------------------------------------------
# π Web Development Hooks (LINTING ONLY)
# -----------------------------------------------------------------------------
# - repo: https://github.com/pre-commit/mirrors-eslint
# rev: v8.50.0
# hooks:
# - id: eslint
# name: π ESLint - JavaScript/TypeScript Linter
# description: Find and fix problems in your JavaScript code.
# files: \.(js|jsx|ts|tsx)$
# types: [file]
# - repo: https://github.com/thibaudcolas/pre-commit-stylelint
# rev: v16.20.0
# hooks:
# - id: stylelint
# name: π Stylelint - CSS Linter
# description: A mighty, modern linter that helps you avoid errors and enforce conventions in your styles.
# files: \.(css|scss|sass|less)$
# -----------------------------------------------------------------------------
# π Performance and Optimization Hooks (MODIFIES FILES)
# -----------------------------------------------------------------------------
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-crlf
name: π Remove CRLF
description: Replaces CRLF line endings by LF.
- id: remove-tabs
name: π Remove Tabs
description: Replaces tabs by whitespaces.
# exclude root-level Makefiles and any path ending in /Makefile or .mk or .jinja
exclude: '(^|/)Makefile$|(\.mk|\.jinja)$'
# -----------------------------------------------------------------------------
# π« Branch Protection Hooks
# -----------------------------------------------------------------------------
# - repo: https://github.com/pre-commit/pre-commit-hooks
# rev: v5.0.0
# hooks:
# - id: no-commit-to-branch
# name: π« Prevent Commits to Protected Branches
# description: Prevents commits to specified branches.
# pass_filenames: false
# always_run: true
# args: [--branch, main, --branch, master, --branch, develop]
# -----------------------------------------------------------------------------
# π Documentation Hooks (MODIFIES FILES)
# -----------------------------------------------------------------------------
# - repo: https://github.com/executablebooks/mdformat
# rev: 0.7.17
# hooks:
# - id: mdformat
# name: π MDFormat - Markdown Formatter
# description: An opinionated Markdown formatter.
# additional_dependencies:
# - mdformat-gfm
# - mdformat-tables
# - mdformat-black
# -----------------------------------------------------------------------------
# π§ͺ DOCTEST VALIDATION
# -----------------------------------------------------------------------------
# - repo: local
# hooks:
# - id: doctest
# name: π§ͺ Doctest - Validate Documentation Examples
# description: Runs doctest on all Python modules to ensure documentation examples work.
# entry: python3 -m pytest --doctest-modules mcpgateway/ --tb=short
# language: system
# pass_filenames: false
# always_run: true
# types: [python]
# -----------------------------------------------------------------------------
# Interrogate
# -----------------------------------------------------------------------------
- repo: https://github.com/econchick/interrogate
rev: 1.7.0 # or master if you're bold
hooks:
- id: interrogate
args: [--quiet, --fail-under=100]
files: ^mcpgateway/