ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / platform / mcp / test / common / allowedMcpServers.test.ts 168 строк · изменён 14 нояб., 04:52
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
import assert from 'assert' ;
import { URI } from '../../../../base/common/uri.js' ;
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js' ;
import { checkMcpServerAllowed, getMcpServerMatchers, IMcpServerMatcher, isMcpServerMatched, McpServerAllowResult } from '../../common/allowedMcpServers.js' ;
suite ( 'AllowedMcpServers' , ( ) => {
ensureNoDisposablesAreLeakedInTestSuite ( ) ;
suite ( 'getMcpServerMatchers' , ( ) =>
assert
assert
assert
assert
assert allowed
assert
value
serverName
serverUrl
serverCommand
serverName
serverCommand
serverCommand
serverName serverUrl
assert value
serverName
serverUrl
serverCommand
assert name
assert name
matchers IMcpServerMatcher serverName
assert matchers name
assert matchers name
matchers IMcpServerMatcher serverUrl
assert matchers name url
assert matchers name url
assert matchers name url
assert matchers name url
assert matchers name url
assert matchers name command
matchers IMcpServerMatcher serverUrl
assert matchers name url
assert matchers name url
originOnly IMcpServerMatcher serverUrl
defaultPort IMcpServerMatcher serverUrl
anyPort IMcpServerMatcher serverUrl
denyDefaultPort IMcpServerMatcher serverUrl
assert
originOnly name url
originOnly name url
originOnly name url
defaultPort name url
defaultPort name url
anyPort name url
anyPort name url
anyPort name url
denyDefaultPort name url
denyDefaultPort name url
McpServerAllowResult Denied
McpServerAllowResult Denied
matchers IMcpServerMatcher serverUrl
cases url allowed
url allowed
url allowed
url allowed
url allowed
url allowed
url allowed
url allowed
url allowed
url allowed
url allowed
url allowed
assert
cases url matchers name url
cases allowed allowed
matchers IMcpServerMatcher serverCommand
assert matchers name command
assert matchers name command
assert matchers name command
assert matchers name url
assert name McpServerAllowResult Allowed
assert name McpServerAllowResult NotAllowed
allow IMcpServerMatcher serverName
assert allow name McpServerAllowResult Allowed
assert allow name McpServerAllowResult NotAllowed
allow IMcpServerMatcher serverName
deny IMcpServerMatcher serverName
assert allow deny name McpServerAllowResult Denied
deny IMcpServerMatcher serverUrl
assert deny name url McpServerAllowResult Denied
assert deny name url McpServerAllowResult Allowed
{
test
(
'coerces non-arrays to undefined'
,
(
)
=>
{
.
strictEqual
(
getMcpServerMatchers
(
null
)
,
undefined
)
;
.
strictEqual
(
getMcpServerMatchers
(
undefined
)
,
undefined
)
;
.
strictEqual
(
getMcpServerMatchers
(
true
)
,
undefined
)
;
.
strictEqual
(
getMcpServerMatchers
(
'[]'
)
,
undefined
)
;
.
strictEqual
(
getMcpServerMatchers
(
{
:
[
]
}
)
,
undefined
)
;
}
)
;
test
(
'empty array is preserved'
,
(
)
=>
{
.
deepStrictEqual
(
getMcpServerMatchers
(
[
]
)
,
[
]
)
;
}
)
;
test
(
'drops malformed and multi-field matcher entries'
,
(
)
=>
{
const
=
[
{
:
'github'
}
,
{
:
'https://mcp.example.com/*'
}
,
{
:
[
'npx'
,
'-y'
,
'server'
]
}
,
{
:
''
}
,
{
:
[
]
}
,
{
:
[
'ok'
,
5
]
}
,
{
:
'a'
,
:
'b'
}
,
{
}
,
'string-entry'
,
]
;
.
deepStrictEqual
(
getMcpServerMatchers
(
)
,
[
{
:
'github'
}
,
{
:
'https://mcp.example.com/*'
}
,
{
:
[
'npx'
,
'-y'
,
'server'
]
}
,
]
)
;
}
)
;
}
)
;
suite
(
'isMcpServerMatched'
,
(
)
=>
{
test
(
'undefined and empty match nothing'
,
(
)
=>
{
.
strictEqual
(
isMcpServerMatched
(
undefined
,
{
:
'x'
}
)
,
false
)
;
.
strictEqual
(
isMcpServerMatched
(
[
]
,
{
:
'x'
}
)
,
false
)
;
}
)
;
test
(
'matches by server name'
,
(
)
=>
{
const
:
[
]
=
[
{
:
'github'
}
]
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
'github'
}
)
,
true
)
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
'gitlab'
}
)
,
false
)
;
}
)
;
test
(
'matches by remote URL with wildcards, case-insensitively'
,
(
)
=>
{
const
:
[
]
=
[
{
:
'https://*.example.com/*'
}
]
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
's'
,
:
'https://mcp.example.com/api'
}
)
,
true
)
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
's'
,
:
'https://MCP.EXAMPLE.COM/api'
}
)
,
true
)
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
's'
,
:
'https://example.com/api'
}
)
,
false
)
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
's'
,
:
'https://mcp.evil.com/api'
}
)
,
false
)
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
's'
,
:
'https://evil.test/.example.com/tool'
}
)
,
false
)
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
's'
,
:
[
'node'
,
'x.js'
]
}
)
,
false
)
;
}
)
;
test
(
'exact URL pattern matches only that URL'
,
(
)
=>
{
const
:
[
]
=
[
{
:
'https://mcp.example.com/mcp'
}
]
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
's'
,
:
'https://mcp.example.com/mcp'
}
)
,
true
)
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
's'
,
:
'https://mcp.example.com/mcp/extra'
}
)
,
false
)
;
}
)
;
test
(
'HTTP(S) patterns match default ports and origin-only spellings'
,
(
)
=>
{
const
:
[
]
=
[
{
:
'https://mcp.example.com'
}
]
;
const
:
[
]
=
[
{
:
'https://mcp.example.com:443/*'
}
]
;
const
:
[
]
=
[
{
:
'http://127.0.0.2:*/*'
}
]
;
const
:
[
]
=
[
{
:
'https://blocked.example:443/*'
}
]
;
.
deepStrictEqual
(
[
isMcpServerMatched
(
,
{
:
's'
,
:
'https://mcp.example.com'
}
)
,
isMcpServerMatched
(
,
{
:
's'
,
:
'https://mcp.example.com/'
}
)
,
isMcpServerMatched
(
,
{
:
's'
,
:
'https://mcp.example.com/extra'
}
)
,
isMcpServerMatched
(
,
{
:
's'
,
:
'https://mcp.example.com/mcp'
}
)
,
isMcpServerMatched
(
,
{
:
's'
,
:
'https://mcp.example.com:443/mcp'
}
)
,
isMcpServerMatched
(
,
{
:
's'
,
:
'http://127.0.0.2/mcp'
}
)
,
isMcpServerMatched
(
,
{
:
's'
,
:
'http://127.0.0.2:80/mcp'
}
)
,
isMcpServerMatched
(
,
{
:
's'
,
:
'http://127.0.0.2:63366/mcp'
}
)
,
checkMcpServerAllowed
(
undefined
,
,
{
:
's'
,
:
'https://blocked.example:443/mcp'
}
)
,
checkMcpServerAllowed
(
undefined
,
,
{
:
's'
,
:
'https://blocked.example/mcp'
}
)
,
]
,
[
true
,
true
,
false
,
true
,
true
,
true
,
true
,
true
,
.
,
.
,
]
)
;
}
)
;
test
(
'URL patterns match the fetch destination rather than the raw spelling'
,
(
)
=>
{
const
:
[
]
=
[
{
:
'http://*127.0.0.2:*/*'
}
]
;
const
:
{
:
string
;
:
boolean
}
[
]
=
[
{
:
'http://127.0.0.2:63366/mcp'
,
:
true
}
,
{
:
'http://127.0.0.1:63365/mcp'
,
:
false
}
,
{
:
'http://127.0.0.1:63365/@127.0.0.2:63366/mcp'
,
:
false
}
,
{
:
'http://127.0.0.1:63365\\@127.0.0.2:63366/mcp'
,
:
false
}
,
{
:
'http://127.0.0.1:63365\\@127.0.0.2:63366\\mcp'
,
:
false
}
,
{
:
'http://127.0.0.2%5C@127.0.0.1:63365/mcp'
,
:
false
}
,
{
:
'http://127.0.0.2:80@127.0.0.1:63365/mcp'
,
:
false
}
,
{
:
'http://127.0.0.2:63366\\extra/mcp'
,
:
true
}
,
{
:
'http://127.0.0.1:63365%5C@127.0.0.2:63366/mcp'
,
:
true
}
,
{
:
URI
.
parse
(
'http://127.0.0.1:63365\\@127.0.0.2:63366/mcp'
)
.
toString
(
true
)
,
:
false
}
,
{
:
'not a url'
,
:
false
}
,
]
;
.
deepStrictEqual
(
.
map
(
(
{
}
)
=>
isMcpServerMatched
(
,
{
:
's'
,
}
)
)
,
.
map
(
(
{
}
)
=>
)
,
)
;
}
)
;
test
(
'matches by local command as an ordered argument list'
,
(
)
=>
{
const
:
[
]
=
[
{
:
[
'npx'
,
'-y'
,
'server'
]
}
]
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
's'
,
:
[
'npx'
,
'-y'
,
'server'
]
}
)
,
true
)
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
's'
,
:
[
'npx'
,
'server'
]
}
)
,
false
)
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
's'
,
:
[
'npx'
,
'-y'
,
'server'
,
'--flag'
]
}
)
,
false
)
;
.
strictEqual
(
isMcpServerMatched
(
,
{
:
's'
,
:
'https://mcp.example.com'
}
)
,
false
)
;
}
)
;
}
)
;
suite
(
'checkMcpServerAllowed'
,
(
)
=>
{
test
(
'no lists configured allows everything'
,
(
)
=>
{
.
strictEqual
(
checkMcpServerAllowed
(
undefined
,
undefined
,
{
:
'x'
}
)
,
.
)
;
}
)
;
test
(
'empty allowlist blocks everything as NotAllowed'
,
(
)
=>
{
.
strictEqual
(
checkMcpServerAllowed
(
[
]
,
undefined
,
{
:
'x'
}
)
,
.
)
;
}
)
;
test
(
'allowlist permits only matching servers'
,
(
)
=>
{
const
:
[
]
=
[
{
:
'github'
}
]
;
.
strictEqual
(
checkMcpServerAllowed
(
,
undefined
,
{
:
'github'
}
)
,
.
)
;
.
strictEqual
(
checkMcpServerAllowed
(
,
undefined
,
{
:
'other'
}
)
,
.
)
;
}
)
;
test
(
'deny takes precedence over allow'
,
(
)
=>
{
const
:
[
]
=
[
{
:
'github'
}
]
;
const
:
[
]
=
[
{
:
'github'
}
]
;
.
strictEqual
(
checkMcpServerAllowed
(
,
,
{
:
'github'
}
)
,
.
)
;
}
)
;
test
(
'deny blocks even when no allowlist is configured'
,
(
)
=>
{
const
:
[
]
=
[
{
:
'https://*.untrusted.example.com/*'
}
]
;
.
strictEqual
(
checkMcpServerAllowed
(
undefined
,
,
{
:
's'
,
:
'https://api.untrusted.example.com/mcp'
}
)
,
.
)
;
.
strictEqual
(
checkMcpServerAllowed
(
undefined
,
,
{
:
's'
,
:
'https://api.trusted.example.com/mcp'
}
)
,
.
)
;
}
)
;
}
)
;
}
)
;