mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add coder_workspace_read_file MCP tool (#19562)
Follows similarly to the bash tool (and some code to connect to an agent was extracted from it). There are two main parts: a new agent endpoint, and then a new MCP tool that consumes that endpoint.
This commit is contained in:
@@ -120,6 +120,27 @@ func (p *QueryParamParser) PositiveInt32(vals url.Values, def int32, queryParam
|
||||
return v
|
||||
}
|
||||
|
||||
// PositiveInt64 function checks if the given value is 64-bit and positive.
|
||||
func (p *QueryParamParser) PositiveInt64(vals url.Values, def int64, queryParam string) int64 {
|
||||
v, err := parseQueryParam(p, vals, func(v string) (int64, error) {
|
||||
intValue, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if intValue < 0 {
|
||||
return 0, xerrors.Errorf("value is negative")
|
||||
}
|
||||
return intValue, nil
|
||||
}, def, queryParam)
|
||||
if err != nil {
|
||||
p.Errors = append(p.Errors, codersdk.ValidationError{
|
||||
Field: queryParam,
|
||||
Detail: fmt.Sprintf("Query param %q must be a valid 64-bit positive integer: %s", queryParam, err.Error()),
|
||||
})
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// NullableBoolean will return a null sql value if no input is provided.
|
||||
// SQLc still uses sql.NullBool rather than the generic type. So converting from
|
||||
// the generic type is required.
|
||||
|
||||
Reference in New Issue
Block a user