Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit348a2e0

Browse files
authored
feat: add configs for external auth MCP usage + tool allow/denylist (#19794)
Closescoder/internal#988The logic for allowing/denying tools can be found inhttps://github.com/coder/aibridge/pull/4/files#diff-330a6371a583dd8cadeed79b95499e3a87960ad8ea4d6a94061e8f88a44834c3 (`ProxyBase.filterAllowedTools`).
1 parent655a36c commit348a2e0

File tree

11 files changed

+88
-0
lines changed

11 files changed

+88
-0
lines changed

‎cli/server.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,6 +2722,12 @@ func parseExternalAuthProvidersFromEnv(prefix string, environ []string) ([]coder
27222722
provider.DisplayName=v.Value
27232723
case"DISPLAY_ICON":
27242724
provider.DisplayIcon=v.Value
2725+
case"MCP_URL":
2726+
provider.MCPURL=v.Value
2727+
case"MCP_TOOL_ALLOW_REGEX":
2728+
provider.MCPToolAllowRegex=v.Value
2729+
case"MCP_TOOL_DENY_REGEX":
2730+
provider.MCPToolDenyRegex=v.Value
27252731
}
27262732
providers[providerNum]=provider
27272733
}

‎coderd/apidoc/docs.go‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/externalauth/externalauth.go‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ type Config struct {
8181
// AppInstallationsURL is an API endpoint that returns a list of
8282
// installations for the user. This is used for GitHub Apps.
8383
AppInstallationsURLstring
84+
// MCPURL is the endpoint that clients must use to communicate with the associated
85+
// MCP server.
86+
MCPURLstring
87+
// MCPToolAllowRegex is a [regexp.Regexp] to match tools which are explicitly allowed to be
88+
// injected into Coder AI Bridge upstream requests.
89+
// In the case of conflicts, [MCPToolDenylistPattern] overrides items evaluated by this list.
90+
// This field can be nil if unspecified in the config.
91+
MCPToolAllowRegex*regexp.Regexp
92+
// MCPToolDenyRegex is a [regexp.Regexp] to match tools which are explicitly NOT allowed to be
93+
// injected into Coder AI Bridge upstream requests.
94+
// In the case of conflicts, items evaluated by this list override [MCPToolAllowRegex].
95+
// This field can be nil if unspecified in the config.
96+
MCPToolDenyRegex*regexp.Regexp
8497
}
8598

8699
// GenerateTokenExtra generates the extra token data to store in the database.
@@ -608,6 +621,21 @@ func ConvertConfig(instrument *promoauth.Factory, entries []codersdk.ExternalAut
608621
instrumented=instrument.NewGithub(entry.ID,oauthConfig)
609622
}
610623

624+
varmcpToolAllow*regexp.Regexp
625+
varmcpToolDeny*regexp.Regexp
626+
ifentry.MCPToolAllowRegex!="" {
627+
mcpToolAllow,err=regexp.Compile(entry.MCPToolAllowRegex)
628+
iferr!=nil {
629+
returnnil,xerrors.Errorf("compile MCP tool allow regex for external auth provider %q: %w",entry.ID,entry.MCPToolAllowRegex)
630+
}
631+
}
632+
ifentry.MCPToolDenyRegex!="" {
633+
mcpToolDeny,err=regexp.Compile(entry.MCPToolDenyRegex)
634+
iferr!=nil {
635+
returnnil,xerrors.Errorf("compile MCP tool deny regex for external auth provider %q: %w",entry.ID,entry.MCPToolDenyRegex)
636+
}
637+
}
638+
611639
cfg:=&Config{
612640
InstrumentedOAuth2Config:instrumented,
613641
ID:entry.ID,
@@ -620,6 +648,9 @@ func ConvertConfig(instrument *promoauth.Factory, entries []codersdk.ExternalAut
620648
DisplayName:entry.DisplayName,
621649
DisplayIcon:entry.DisplayIcon,
622650
ExtraTokenKeys:entry.ExtraTokenKeys,
651+
MCPURL:entry.MCPURL,
652+
MCPToolAllowRegex:mcpToolAllow,
653+
MCPToolDenyRegex:mcpToolDeny,
623654
}
624655

625656
ifentry.DeviceFlow {

‎codersdk/deployment.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,9 @@ type ExternalAuthConfig struct {
742742
ExtraTokenKeys []string`json:"-" yaml:"extra_token_keys"`
743743
DeviceFlowbool`json:"device_flow" yaml:"device_flow"`
744744
DeviceCodeURLstring`json:"device_code_url" yaml:"device_code_url"`
745+
MCPURLstring`json:"mcp_url" yaml:"mcp_url"`
746+
MCPToolAllowRegexstring`json:"mcp_tool_allow_regex" yaml:"mcp_tool_allow_regex"`
747+
MCPToolDenyRegexstring`json:"mcp_tool_deny_regex" yaml:"mcp_tool_deny_regex"`
745748
// Regex allows API requesters to match an auth config by
746749
// a string (e.g. coder.com) instead of by it's type.
747750
//

‎codersdk/deployment_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,9 @@ func TestExternalAuthYAMLConfig(t *testing.T) {
399399
Regex:"^https://example.com/.*$",
400400
DisplayName:"GitHub",
401401
DisplayIcon:"/static/icons/github.svg",
402+
MCPURL:"https://api.githubcopilot.com/mcp/",
403+
MCPToolAllowRegex:".*",
404+
MCPToolDenyRegex:"create_gist",
402405
}
403406

404407
// Input the github section twice for testing a slice of configs.

‎codersdk/testdata/githubcfg.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ externalAuthProviders:
1717
-token
1818
device_flow:true
1919
device_code_url:https://example.com/device
20+
mcp_url:https://api.githubcopilot.com/mcp/
21+
mcp_tool_allow_regex:.*
22+
mcp_tool_deny_regex:create_gist
2023
regex:^https://example.com/.*$
2124
display_name:GitHub
2225
display_icon:/static/icons/github.svg

‎docs/reference/api/general.md‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/reference/api/schemas.md‎

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎site/src/api/typesGenerated.ts‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp