Commit f671053
feat(api): auto-populate REST tool schemas from OpenAPI specs (#3167)
* input_schema
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* toolupdate change
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* lint
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* test case fix
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* missing testcases
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* missing coverage fix
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* remove
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* docstring
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* edittool
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* review
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* lint
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* add button
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* outshcem fix in admin ui
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* output_schema
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* openai endpoint fix
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* docstring
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* test case fix
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* refactor
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* refactor
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* doctest
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* pylint
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* test coverage
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* pre-commit
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* remove doc file
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* lint fix
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
* fix: harden OpenAPI schema endpoint — SSRF, size limits, dead code removal
Security:
- Disable HTTP redirects (follow_redirects=False) to prevent SSRF bypass
via attacker-controlled 302 redirects to internal addresses
- Add 10 MiB response size cap to prevent memory exhaustion from
malicious servers
- Remove broken frontend buttons that called undefined JS functions
- Require 'url' parameter (not just openapi_url) to prevent empty URL
parsing producing invalid base_url/path
Complexity reduction (-1,900 lines):
- Remove unused extract_all_schemas_from_openapi and
fetch_and_extract_all_schemas (zero production callers)
- Extract _extract_rest_url_components helper to deduplicate URL parsing
in ToolCreate and ToolUpdate validators
- Remove excessive doctests that duplicated unit test coverage
- Collapse phantom tests mocking requests.get (never called by validators)
into focused tests of actual validator behaviour
- Consolidate admin endpoint error-mapping tests via parametrize
- Remove unused _db dependency from endpoint signature
- Remove debug logging from ToolCreate validator
Closes #2784
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Springer <jps@s390x.com>
---------
Signed-off-by: Rakhi Dutta <rakhibiswas@yahoo.com>
Signed-off-by: Jonathan Springer <jps@s390x.com>
Co-authored-by: Rakhi Dutta <rakhibiswas@yahoo.com>
Co-authored-by: Jonathan Springer <jps@s390x.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 5be0dbc commit f671053
9 files changed
Lines changed: 1265 additions & 66 deletions
File tree
- mcpgateway
- services
- tests/unit/mcpgateway
- services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
5086 | 5086 | | |
5087 | 5087 | | |
5088 | 5088 | | |
5089 | | - | |
| 5089 | + | |
5090 | 5090 | | |
5091 | 5091 | | |
5092 | 5092 | | |
5093 | 5093 | | |
5094 | 5094 | | |
5095 | 5095 | | |
5096 | 5096 | | |
5097 | | - | |
| 5097 | + | |
5098 | 5098 | | |
5099 | 5099 | | |
5100 | 5100 | | |
5101 | 5101 | | |
5102 | 5102 | | |
5103 | 5103 | | |
5104 | 5104 | | |
5105 | | - | |
| 5105 | + | |
5106 | 5106 | | |
5107 | 5107 | | |
5108 | 5108 | | |
5109 | 5109 | | |
5110 | 5110 | | |
5111 | 5111 | | |
5112 | 5112 | | |
5113 | | - | |
| 5113 | + | |
5114 | 5114 | | |
5115 | 5115 | | |
5116 | 5116 | | |
| |||
5962 | 5962 | | |
5963 | 5963 | | |
5964 | 5964 | | |
5965 | | - | |
| 5965 | + | |
5966 | 5966 | | |
5967 | 5967 | | |
5968 | 5968 | | |
5969 | 5969 | | |
5970 | 5970 | | |
5971 | 5971 | | |
5972 | 5972 | | |
5973 | | - | |
| 5973 | + | |
5974 | 5974 | | |
5975 | 5975 | | |
5976 | 5976 | | |
5977 | 5977 | | |
5978 | 5978 | | |
5979 | 5979 | | |
5980 | 5980 | | |
5981 | | - | |
| 5981 | + | |
5982 | 5982 | | |
5983 | 5983 | | |
5984 | 5984 | | |
5985 | 5985 | | |
5986 | 5986 | | |
5987 | 5987 | | |
5988 | 5988 | | |
5989 | | - | |
| 5989 | + | |
5990 | 5990 | | |
5991 | 5991 | | |
5992 | 5992 | | |
5993 | 5993 | | |
5994 | 5994 | | |
5995 | 5995 | | |
5996 | 5996 | | |
5997 | | - | |
| 5997 | + | |
5998 | 5998 | | |
5999 | 5999 | | |
6000 | 6000 | | |
6001 | 6001 | | |
6002 | 6002 | | |
6003 | 6003 | | |
6004 | 6004 | | |
6005 | | - | |
| 6005 | + | |
6006 | 6006 | | |
6007 | 6007 | | |
6008 | 6008 | | |
| |||
9958 | 9958 | | |
9959 | 9959 | | |
9960 | 9960 | | |
9961 | | - | |
| 9961 | + | |
9962 | 9962 | | |
9963 | 9963 | | |
9964 | 9964 | | |
9965 | 9965 | | |
9966 | 9966 | | |
9967 | 9967 | | |
9968 | 9968 | | |
9969 | | - | |
| 9969 | + | |
9970 | 9970 | | |
9971 | 9971 | | |
9972 | 9972 | | |
9973 | 9973 | | |
9974 | 9974 | | |
9975 | 9975 | | |
9976 | 9976 | | |
9977 | | - | |
| 9977 | + | |
9978 | 9978 | | |
9979 | 9979 | | |
9980 | 9980 | | |
9981 | 9981 | | |
9982 | 9982 | | |
9983 | 9983 | | |
9984 | 9984 | | |
9985 | | - | |
| 9985 | + | |
9986 | 9986 | | |
9987 | 9987 | | |
9988 | 9988 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
| |||
11772 | 11773 | | |
11773 | 11774 | | |
11774 | 11775 | | |
| 11776 | + | |
| 11777 | + | |
| 11778 | + | |
| 11779 | + | |
| 11780 | + | |
| 11781 | + | |
| 11782 | + | |
| 11783 | + | |
| 11784 | + | |
| 11785 | + | |
| 11786 | + | |
| 11787 | + | |
| 11788 | + | |
| 11789 | + | |
| 11790 | + | |
| 11791 | + | |
| 11792 | + | |
| 11793 | + | |
| 11794 | + | |
| 11795 | + | |
| 11796 | + | |
| 11797 | + | |
| 11798 | + | |
| 11799 | + | |
| 11800 | + | |
| 11801 | + | |
| 11802 | + | |
| 11803 | + | |
| 11804 | + | |
| 11805 | + | |
| 11806 | + | |
| 11807 | + | |
| 11808 | + | |
| 11809 | + | |
| 11810 | + | |
| 11811 | + | |
| 11812 | + | |
| 11813 | + | |
| 11814 | + | |
| 11815 | + | |
| 11816 | + | |
| 11817 | + | |
| 11818 | + | |
| 11819 | + | |
| 11820 | + | |
| 11821 | + | |
| 11822 | + | |
| 11823 | + | |
| 11824 | + | |
| 11825 | + | |
| 11826 | + | |
| 11827 | + | |
| 11828 | + | |
| 11829 | + | |
| 11830 | + | |
| 11831 | + | |
| 11832 | + | |
| 11833 | + | |
| 11834 | + | |
| 11835 | + | |
| 11836 | + | |
| 11837 | + | |
| 11838 | + | |
| 11839 | + | |
| 11840 | + | |
| 11841 | + | |
| 11842 | + | |
| 11843 | + | |
| 11844 | + | |
| 11845 | + | |
| 11846 | + | |
| 11847 | + | |
| 11848 | + | |
| 11849 | + | |
| 11850 | + | |
| 11851 | + | |
| 11852 | + | |
| 11853 | + | |
| 11854 | + | |
| 11855 | + | |
| 11856 | + | |
| 11857 | + | |
| 11858 | + | |
| 11859 | + | |
| 11860 | + | |
| 11861 | + | |
| 11862 | + | |
| 11863 | + | |
| 11864 | + | |
| 11865 | + | |
| 11866 | + | |
| 11867 | + | |
| 11868 | + | |
| 11869 | + | |
| 11870 | + | |
| 11871 | + | |
| 11872 | + | |
| 11873 | + | |
| 11874 | + | |
| 11875 | + | |
| 11876 | + | |
| 11877 | + | |
| 11878 | + | |
| 11879 | + | |
| 11880 | + | |
| 11881 | + | |
| 11882 | + | |
| 11883 | + | |
| 11884 | + | |
| 11885 | + | |
| 11886 | + | |
| 11887 | + | |
| 11888 | + | |
| 11889 | + | |
| 11890 | + | |
| 11891 | + | |
| 11892 | + | |
| 11893 | + | |
11775 | 11894 | | |
11776 | 11895 | | |
11777 | 11896 | | |
| |||
0 commit comments