Skip to content

Commit 06e2eca

Browse files
Add Field descriptions
1 parent 0c7aac2 commit 06e2eca

File tree

1 file changed

+88
-44
lines changed

1 file changed

+88
-44
lines changed

src/seclab_taskflows/mcp_servers/repo_context.py

Lines changed: 88 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -340,18 +340,22 @@ def process_repo(owner, repo):
340340
return f"{owner}/{repo}".lower()
341341

342342
@mcp.tool()
343-
def store_new_component(owner: str, repo: str, location: str = Field(description="The directory of the component"),
344-
is_app: bool = Field(description="Is this an application", default=None),
345-
is_library: bool = Field(description="Is this a library", default=None),
346-
notes: str = Field(description="The notes taken for this component", default="")):
343+
def store_new_component(owner: str = Field(description="The owner of the GitHub repository"),
344+
repo: str = Field(description="The name of the GitHub repository"),
345+
location: str = Field(description="The directory of the component"),
346+
is_app: bool = Field(description="Is this an application", default=None),
347+
is_library: bool = Field(description="Is this a library", default=None),
348+
notes: str = Field(description="The notes taken for this component", default="")):
347349
"""
348350
Stores a new component in the database.
349351
"""
350352
return backend.store_new_application(process_repo(owner, repo), location, is_app, is_library, notes)
351353

352354
@mcp.tool()
353-
def add_component_notes(owner: str, repo: str, location: str = Field(description="The directory of the component", default=None),
354-
notes: str = Field(description="New notes taken for this component", default="")):
355+
def add_component_notes(owner: str = Field(description="The owner of the GitHub repository"),
356+
repo: str = Field(description="The name of the GitHub repository"),
357+
location: str = Field(description="The directory of the component", default=None),
358+
notes: str = Field(description="New notes taken for this component", default="")):
355359
"""
356360
Add new notes to a component
357361
"""
@@ -362,7 +366,9 @@ def add_component_notes(owner: str, repo: str, location: str = Field(description
362366
return backend.store_new_application(repo, location, None, None, notes)
363367

364368
@mcp.tool()
365-
def store_new_entry_point(owner: str, repo: str, location: str = Field(description="The directory of the component where the entry point belonged to"),
369+
def store_new_entry_point(owner: str = Field(description="The owner of the GitHub repository"),
370+
repo: str = Field(description="The name of the GitHub repository"),
371+
location: str = Field(description="The directory of the component where the entry point belonged to"),
366372
file: str = Field(description="The file that contains the entry point"),
367373
line: int = Field(description="The file line that contains the entry point"),
368374
user_input: str = Field(description="The variables that are considered as user input"),
@@ -377,44 +383,53 @@ def store_new_entry_point(owner: str, repo: str, location: str = Field(descripti
377383
return backend.store_new_entry_point(repo, app.id, file, user_input, line, notes)
378384

379385
@mcp.tool()
380-
def store_new_component_issue(owner: str, repo: str, component_id: int,
381-
issue_type: str, notes: str):
386+
def store_new_component_issue(owner: str = Field(description="The owner of the GitHub repository"),
387+
repo: str = Field(description="The name of the GitHub repository"),
388+
component_id: int = Field(description="The ID of the component"),
389+
issue_type: str = Field(description="The type of issue"),
390+
notes: str = Field(description="Notes about the issue")):
382391
"""
383392
Stores a type of common issue for a component.
384393
"""
385394
repo = process_repo(owner, repo)
386395
return backend.store_new_component_issue(repo, component_id, issue_type, notes)
387396

388397
@mcp.tool()
389-
def store_new_audit_result(owner: str, repo: str, component_id: int, issue_type: str, issue_id: int,
390-
has_non_security_error: bool = Field(description="Set to true if there are security issues or logic error but may not be exploitable"),
391-
has_vulnerability: bool = Field(description="Set to true if a security vulnerability is identified"),
392-
notes: str = Field(description="The notes for the audit of this issue")):
398+
def store_new_audit_result(owner: str = Field(description="The owner of the GitHub repository"),
399+
repo: str = Field(description="The name of the GitHub repository"),
400+
component_id: int = Field(description="The ID of the component"),
401+
issue_type: str = Field(description="The type of issue"),
402+
issue_id: int = Field(description="The ID of the issue"),
403+
has_non_security_error: bool = Field(description="Set to true if there are security issues or logic error but may not be exploitable"),
404+
has_vulnerability: bool = Field(description="Set to true if a security vulnerability is identified"),
405+
notes: str = Field(description="The notes for the audit of this issue")):
393406
"""
394407
Stores the audit result for issue with issue_id.
395408
"""
396409
repo = process_repo(owner, repo)
397410
return backend.store_new_audit_result(repo, component_id, issue_type, issue_id, has_non_security_error, has_vulnerability, notes)
398411

399412
@mcp.tool()
400-
def store_new_web_entry_point(owner: str, repo: str,
401-
entry_point_id: int = Field(description="The ID of the entry point this web entry point refers to"),
402-
location: str = Field(description="The directory of the component where the web entry point belongs to"),
403-
method: str = Field(description="HTTP method (GET, POST, etc)", default=""),
404-
path: str = Field(description="URL path (e.g., /info)", default=""),
405-
component: int = Field(description="Component identifier", default=0),
406-
auth: str = Field(description="Authentication information", default=""),
407-
middleware: str = Field(description="Middleware information", default=""),
408-
roles_scopes: str = Field(description="Roles and scopes information", default=""),
409-
notes: str = Field(description="Notes for this web entry point", default="")):
413+
def store_new_web_entry_point(owner: str = Field(description="The owner of the GitHub repository"),
414+
repo: str = Field(description="The name of the GitHub repository"),
415+
entry_point_id: int = Field(description="The ID of the entry point this web entry point refers to"),
416+
location: str = Field(description="The directory of the component where the web entry point belongs to"),
417+
method: str = Field(description="HTTP method (GET, POST, etc)", default=""),
418+
path: str = Field(description="URL path (e.g., /info)", default=""),
419+
component: int = Field(description="Component identifier", default=0),
420+
auth: str = Field(description="Authentication information", default=""),
421+
middleware: str = Field(description="Middleware information", default=""),
422+
roles_scopes: str = Field(description="Roles and scopes information", default=""),
423+
notes: str = Field(description="Notes for this web entry point", default="")):
410424
"""
411425
Stores a new web entry point in a component to the database. A web entry point extends a regular entry point
412426
with web-specific properties like HTTP method, path, authentication, middleware, and roles/scopes.
413427
"""
414428
return backend.store_new_web_entry_point(process_repo(owner, repo), entry_point_id, method, path, component, auth, middleware, roles_scopes, notes)
415429

416430
@mcp.tool()
417-
def add_entry_point_notes(owner: str, repo: str,
431+
def add_entry_point_notes(owner: str = Field(description="The owner of the GitHub repository"),
432+
repo: str = Field(description="The name of the GitHub repository"),
418433
location: str = Field(description="The directory of the component where the entry point belonged to"),
419434
file: str = Field(description="The file that contains the entry point"),
420435
line: int = Field(description="The file line that contains the entry point"),
@@ -430,9 +445,11 @@ def add_entry_point_notes(owner: str, repo: str,
430445

431446

432447
@mcp.tool()
433-
def store_new_user_action(owner: str, repo: str, location: str = Field(description="The directory of the component where the user action belonged to"),
448+
def store_new_user_action(owner: str = Field(description="The owner of the GitHub repository"),
449+
repo: str = Field(description="The name of the GitHub repository"),
450+
location: str = Field(description="The directory of the component where the user action belonged to"),
434451
file: str = Field(description="The file that contains the user action"),
435-
line: int = Field(description="The file line that contains the user action"),
452+
line: int = Field(description="The file line that contains the user action"),
436453
notes: str = Field(description="New notes for this user action", default = "")):
437454
"""
438455
Stores a new user action in a component to the database.
@@ -444,7 +461,9 @@ def store_new_user_action(owner: str, repo: str, location: str = Field(descripti
444461
return backend.store_new_user_action(repo, app.id, file, line, notes)
445462

446463
@mcp.tool()
447-
def add_user_action_notes(owner: str, repo: str, location: str = Field(description="The directory of the component where the user action belonged to"),
464+
def add_user_action_notes(owner: str = Field(description="The owner of the GitHub repository"),
465+
repo: str = Field(description="The name of the GitHub repository"),
466+
location: str = Field(description="The directory of the component where the user action belonged to"),
448467
file: str = Field(description="The file that contains the user action"),
449468
line: str = Field(description="The file line that contains the user action"),
450469
notes: str = Field(description="The notes for user action", default = "")):
@@ -455,7 +474,9 @@ def add_user_action_notes(owner: str, repo: str, location: str = Field(descripti
455474
return backend.store_new_user_action(repo, app.id, file, line, notes, True)
456475

457476
@mcp.tool()
458-
def get_component(owner: str, repo: str, location: str = Field(description="The directory of the component")):
477+
def get_component(owner: str = Field(description="The owner of the GitHub repository"),
478+
repo: str = Field(description="The name of the GitHub repository"),
479+
location: str = Field(description="The directory of the component")):
459480
"""
460481
The a component from the database
461482
"""
@@ -466,127 +487,150 @@ def get_component(owner: str, repo: str, location: str = Field(description="The
466487
return json.dumps(app_to_dict(app))
467488

468489
@mcp.tool()
469-
def get_components(owner: str, repo: str):
490+
def get_components(owner: str = Field(description="The owner of the GitHub repository"),
491+
repo: str = Field(description="The name of the GitHub repository")):
470492
"""
471493
Get components from the repo
472494
"""
473495
repo = process_repo(owner, repo)
474496
return json.dumps(backend.get_apps(repo))
475497

476498
@mcp.tool()
477-
def get_entry_points(owner: str, repo: str, location: str = Field(description="The directory of the component")):
499+
def get_entry_points(owner: str = Field(description="The owner of the GitHub repository"),
500+
repo: str = Field(description="The name of the GitHub repository"),
501+
location: str = Field(description="The directory of the component")):
478502
"""
479503
Get all the entry points of a component.
480504
"""
481505
repo = process_repo(owner, repo)
482506
return json.dumps(backend.get_app_entries(repo, location))
483507

484508
@mcp.tool()
485-
def get_entry_points_for_repo(owner: str, repo: str):
509+
def get_entry_points_for_repo(owner: str = Field(description="The owner of the GitHub repository"),
510+
repo: str = Field(description="The name of the GitHub repository")):
486511
"""
487512
Get all entry points of an repo
488513
"""
489514
repo = process_repo(owner, repo)
490515
return json.dumps(backend.get_app_entries_for_repo(repo))
491516

492517
@mcp.tool()
493-
def get_web_entry_points_component(owner: str, repo: str, component_id: int):
518+
def get_web_entry_points_component(owner: str = Field(description="The owner of the GitHub repository"),
519+
repo: str = Field(description="The name of the GitHub repository"),
520+
component_id: int = Field(description="The ID of the component")):
494521
"""
495522
Get all web entry points for a component
496523
"""
497524
repo = process_repo(owner, repo)
498525
return json.dumps(backend.get_web_entries(repo, component_id))
499526

500527
@mcp.tool()
501-
def get_web_entry_points_for_repo(owner: str, repo: str):
528+
def get_web_entry_points_for_repo(owner: str = Field(description="The owner of the GitHub repository"),
529+
repo: str = Field(description="The name of the GitHub repository")):
502530
"""
503531
Get all web entry points of an repo
504532
"""
505533
repo = process_repo(owner, repo)
506534
return json.dumps(backend.get_web_entries_for_repo(repo))
507535

508536
@mcp.tool()
509-
def get_user_actions(owner: str, repo: str, location: str = Field(description="The directory of the component")):
537+
def get_user_actions(owner: str = Field(description="The owner of the GitHub repository"),
538+
repo: str = Field(description="The name of the GitHub repository"),
539+
location: str = Field(description="The directory of the component")):
510540
"""
511541
Get all the user actions in a component.
512542
"""
513543
repo = process_repo(owner, repo)
514544
return json.dumps(backend.get_user_actions(repo, location))
515545

516546
@mcp.tool()
517-
def get_user_actions_for_repo(owner: str, repo: str):
547+
def get_user_actions_for_repo(owner: str = Field(description="The owner of the GitHub repository"),
548+
repo: str = Field(description="The name of the GitHub repository")):
518549
"""
519550
Get all the user actions in a repo.
520551
"""
521552
repo = process_repo(owner, repo)
522553
return json.dumps(backend.get_user_actions_for_repo(repo))
523554

524555
@mcp.tool()
525-
def get_component_issues(owner: str, repo: str, component_id: int):
556+
def get_component_issues(owner: str = Field(description="The owner of the GitHub repository"),
557+
repo: str = Field(description="The name of the GitHub repository"),
558+
component_id: int = Field(description="The ID of the component")):
526559
"""
527560
Get issues for the component.
528561
"""
529562
repo = process_repo(owner, repo)
530563
return json.dumps(backend.get_app_issues(repo, component_id))
531564

532565
@mcp.tool()
533-
def get_component_results(owner: str, repo: str, component_id: int):
566+
def get_component_results(owner: str = Field(description="The owner of the GitHub repository"),
567+
repo: str = Field(description="The name of the GitHub repository"),
568+
component_id: int = Field(description="The ID of the component")):
534569
"""
535570
Get audit results for the component.
536571
"""
537572
repo = process_repo(owner, repo)
538573
return json.dumps(backend.get_app_audit_results(repo, component_id, None, None))
539574

540575
@mcp.tool()
541-
def get_component_vulnerable_results(owner: str, repo: str, component_id: int):
576+
def get_component_vulnerable_results(owner: str = Field(description="The owner of the GitHub repository"),
577+
repo: str = Field(description="The name of the GitHub repository"),
578+
component_id: int = Field(description="The ID of the component")):
542579
"""
543580
Get audit results for the component that are audited as vulnerable.
544581
"""
545582
repo = process_repo(owner, repo)
546583
return json.dumps(backend.get_app_audit_results(repo, component_id, has_non_security_error = None, has_vulnerability = True))
547584

548585
@mcp.tool()
549-
def get_component_potential_results(owner: str, repo: str, component_id: int):
586+
def get_component_potential_results(owner: str = Field(description="The owner of the GitHub repository"),
587+
repo: str = Field(description="The name of the GitHub repository"),
588+
component_id: int = Field(description="The ID of the component")):
550589
"""
551590
Get audit results for the component that are audited as an issue but may not be exploitable.
552591
"""
553592
repo = process_repo(owner, repo)
554593
return json.dumps(backend.get_app_audit_results(repo, component_id, has_non_security_error = True, has_vulnerability = None))
555594

556595
@mcp.tool()
557-
def get_audit_results_for_repo(owner: str, repo: str):
596+
def get_audit_results_for_repo(owner: str = Field(description="The owner of the GitHub repository"),
597+
repo: str = Field(description="The name of the GitHub repository")):
558598
"""
559599
Get audit results for the repo.
560600
"""
561601
repo = process_repo(owner, repo)
562602
return json.dumps(backend.get_app_audit_results(repo, component_id = None, has_non_security_error = None, has_vulnerability = None))
563603

564604
@mcp.tool()
565-
def get_vulnerable_audit_results_for_repo(owner: str, repo: str):
605+
def get_vulnerable_audit_results_for_repo(owner: str = Field(description="The owner of the GitHub repository"),
606+
repo: str = Field(description="The name of the GitHub repository")):
566607
"""
567608
Get audit results for the repo that are audited as vulnerable.
568609
"""
569610
repo = process_repo(owner, repo)
570611
return json.dumps(backend.get_app_audit_results(repo, component_id = None, has_non_security_error = None, has_vulnerability = True))
571612

572613
@mcp.tool()
573-
def get_potential_audit_results_for_repo(owner: str, repo: str):
614+
def get_potential_audit_results_for_repo(owner: str = Field(description="The owner of the GitHub repository"),
615+
repo: str = Field(description="The name of the GitHub repository")):
574616
"""
575617
Get audit results for the repo that are potential issues but may not be exploitable.
576618
"""
577619
repo = process_repo(owner, repo)
578620
return json.dumps(backend.get_app_audit_results(repo, component_id = None, has_non_security_error = True, has_vulnerability = None))
579621

580622
@mcp.tool()
581-
def clear_repo(owner: str, repo: str):
623+
def clear_repo(owner: str = Field(description="The owner of the GitHub repository"),
624+
repo: str = Field(description="The name of the GitHub repository")):
582625
"""
583626
clear all results for repo.
584627
"""
585628
repo = process_repo(owner, repo)
586629
return backend.clear_repo(repo)
587630

588631
@mcp.tool()
589-
def clear_component_issues_for_repo(owner: str, repo: str):
632+
def clear_component_issues_for_repo(owner: str = Field(description="The owner of the GitHub repository"),
633+
repo: str = Field(description="The name of the GitHub repository")):
590634
"""
591635
clear all results for repo.
592636
"""

0 commit comments

Comments
 (0)