GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — mcp: restore workspace module methods in dagger mcp by shykes · Pull Request #13030 · dagger/dagger

Conversation

@shykes

@shykes shykes commented Apr 24, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #13023.

Summary

dagger mcp stopped showing methods from the current workspace module.

The problem was that dagger mcp was still reading methods from module objects installed in the env, while workspace module entrypoints now come from the served Query schema.

This change makes dagger mcp load workspace module methods from the served schema.

After this change:

  • without --env-privileged, dagger mcp shows workspace module methods
  • with --env-privileged, dagger mcp shows workspace module methods and core methods

This also adds integration tests for these cases.

Testing

dagger call -m github.com/dagger/dagger@pull/head/13030 \
  engine-dev \
  test --pkg=./core/integration --run='TestMCP'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@shykes
shykes force-pushed the fix-13023 branch from c0cd37a to 581daee Compare April 24, 2026 20:42
@shykes shykes changed the title mcp: restore served module methods in static mode mcp: restore workspace module methods in dagger mcp Apr 24, 2026
@shykes
shykes force-pushed the fix-13023 branch from e7133ca to 5e0ac1f Compare April 25, 2026 18:05
@shykes
shykes marked this pull request as ready for review April 25, 2026 19:45
@shykes
shykes requested a review from a team as a code owner April 27, 2026 01:13
@shykes
shykes force-pushed the fix-13023 branch 2 times, most recently from 5e0ac1f to aa5b560 Compare April 27, 2026 19:00
shykes added 3 commits April 27, 2026 14:27
@shykes
mcp: restore served module methods in static mode
ed4ad8e
Issue #13023 is a regression in how `dagger mcp` discovers methods for the
current workspace module. Static MCP method calling was still building its tool
set from objects installed in the env. After the workspace/module changes, the
workspace entrypoint methods are exposed on the served `Query` root instead of
always being materialized as installed env objects. That left static MCP with
an empty method list for workspace modules unless privileged mode also exposed
core `Query` methods.

Fix this by loading workspace module query fields from the served schema and
feeding them into the same static method-calling tool set as other callable
methods. The new `loadServedModuleQueryTools` path reads
`currentTypeDefs(hideCore: true)`, finds the module-owned `Query` object, maps
those functions back to the served GraphQL fields, and adds them as top-level
static call methods. The static MCP builtins now operate on a unified
`callMethods` set so module query methods, env-installed module methods, and
reachable object methods are selected and called through the same path.

Add integration coverage for the `dagger mcp` CLI command itself. The new tests
start `dagger mcp` over stdio and verify all four user-facing combinations:
workspace module without `--env-privileged`, no module without
`--env-privileged`, no module with `--env-privileged`, and workspace module
with `--env-privileged`.

Signed-off-by: Solomon Hykes <[email protected]>
@shykes
mcp: pass hideCore as an optional arg
71093bd
The first `TestMCP` cloud run showed that the new workspace method loader was
calling `currentTypeDefs` with the wrong input type for `hideCore`.

That field is declared as `dagql.Optional[dagql.Boolean]`, but the loader was
passing a plain `dagql.Boolean`. That caused `dagger mcp` to fail during tool
loading before the MCP server finished starting, which made the integration
cases fail with `transport closed` and the wrong CLI error.

Wrap the value with `dagql.Opt(...)` so the selector matches the schema's input
shape.

Signed-off-by: Solomon Hykes <[email protected]>
@shykes
mcp: load workspace methods from live schema
48939aa
`dagger mcp` in static tool mode was building the callable top-level method set from the environment dependency schema. That schema is useful for installed modules, reachable object methods, builtins, and other environment-backed behavior, but it does not represent the live workspace `Query` root after the current module has been served as an entrypoint. As a result, workspace functions such as `greeting` disappeared from `ListMethods`; privileged mode could still show core `Query` fields, which made the bug look like a filtering issue even though the actual problem was schema selection.

Split the schema sources used by `MCP.Tools`: load served workspace `Query` methods from `CurrentDagqlServer(ctx)`, and keep the env-backed schema from `m.env.Self().deps.Schema(ctx)` for module tools, reachable object methods, and builtins. The tool closures produced for served query methods retain the same live server they were built from, so `CallMethod` executes against the schema that exposed the workspace entrypoint method.

The same no-module path exposed another stale assumption in `dagger mcp`: `initializeWorkspace` always returns a `moduleDef`, even when no workspace module exists, so the old `modDef == nil` check never fired. That let `dagger mcp` without `--env-privileged` start the MCP server in an empty workspace and block forever. Load the workspace typedefs with core hidden and treat the workspace as module-backed only when Query has a served module function (`sourceModuleName`) or the module constructor `with`, matching the MCP tool loader. Empty workspace plus no `--env-privileged` now fails before starting the server.

The MCP integration coverage exercises the four intended modes: module without privileged, no module without privileged, no module with privileged, and module with privileged. Once workspace methods were actually invoked, module calls could include the existing tool-call log prefix before the string result, so the two module result assertions now verify that the returned content contains the module value instead of asserting exact output formatting.

Verification:
- git diff --check
- GOOS=linux GOARCH=amd64 go test -c ./cmd/dagger -o /tmp/cmd-dagger.test
- GOOS=linux GOARCH=amd64 go test -c ./core/integration -o /tmp/core-integration.test

A remote debug run before the CLI guard fix reproduced the hang with `--timeout=2m --test-verbose`: `TestWithoutModuleAndWithoutPrivilegedFails` was blocked in `hostDaggerExec(..., "mcp")`, waiting for the empty-workspace MCP process to exit. That confirmed the no-module guard needed to be fixed rather than weakening the test.

Signed-off-by: Solomon Hykes <[email protected]>
@shykes
shykes force-pushed the fix-13023 branch from aa5b560 to 48939aa Compare April 27, 2026 21:27
@shykes
shykes requested review from a team, grouville and vito April 27, 2026 23:04
vito
vito approved these changes Apr 27, 2026
View reviewed changes
@shykes
shykes merged commit 092168c into main Apr 27, 2026
2 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@shykes
shykes deleted the fix-13023 branch April 27, 2026 23:18
grouville pushed a commit to grouville/dagger that referenced this pull request Apr 28, 2026
@shykes @grouville
mcp: restore workspace module methods in dagger mcp (dagger#13030)
7357236
* mcp: restore served module methods in static mode

Issue dagger#13023 is a regression in how `dagger mcp` discovers methods for the
current workspace module. Static MCP method calling was still building its tool
set from objects installed in the env. After the workspace/module changes, the
workspace entrypoint methods are exposed on the served `Query` root instead of
always being materialized as installed env objects. That left static MCP with
an empty method list for workspace modules unless privileged mode also exposed
core `Query` methods.

Fix this by loading workspace module query fields from the served schema and
feeding them into the same static method-calling tool set as other callable
methods. The new `loadServedModuleQueryTools` path reads
`currentTypeDefs(hideCore: true)`, finds the module-owned `Query` object, maps
those functions back to the served GraphQL fields, and adds them as top-level
static call methods. The static MCP builtins now operate on a unified
`callMethods` set so module query methods, env-installed module methods, and
reachable object methods are selected and called through the same path.

Add integration coverage for the `dagger mcp` CLI command itself. The new tests
start `dagger mcp` over stdio and verify all four user-facing combinations:
workspace module without `--env-privileged`, no module without
`--env-privileged`, no module with `--env-privileged`, and workspace module
with `--env-privileged`.

Signed-off-by: Solomon Hykes <[email protected]>

* mcp: pass hideCore as an optional arg

The first `TestMCP` cloud run showed that the new workspace method loader was
calling `currentTypeDefs` with the wrong input type for `hideCore`.

That field is declared as `dagql.Optional[dagql.Boolean]`, but the loader was
passing a plain `dagql.Boolean`. That caused `dagger mcp` to fail during tool
loading before the MCP server finished starting, which made the integration
cases fail with `transport closed` and the wrong CLI error.

Wrap the value with `dagql.Opt(...)` so the selector matches the schema's input
shape.

Signed-off-by: Solomon Hykes <[email protected]>

* mcp: load workspace methods from live schema

`dagger mcp` in static tool mode was building the callable top-level method set from the environment dependency schema. That schema is useful for installed modules, reachable object methods, builtins, and other environment-backed behavior, but it does not represent the live workspace `Query` root after the current module has been served as an entrypoint. As a result, workspace functions such as `greeting` disappeared from `ListMethods`; privileged mode could still show core `Query` fields, which made the bug look like a filtering issue even though the actual problem was schema selection.

Split the schema sources used by `MCP.Tools`: load served workspace `Query` methods from `CurrentDagqlServer(ctx)`, and keep the env-backed schema from `m.env.Self().deps.Schema(ctx)` for module tools, reachable object methods, and builtins. The tool closures produced for served query methods retain the same live server they were built from, so `CallMethod` executes against the schema that exposed the workspace entrypoint method.

The same no-module path exposed another stale assumption in `dagger mcp`: `initializeWorkspace` always returns a `moduleDef`, even when no workspace module exists, so the old `modDef == nil` check never fired. That let `dagger mcp` without `--env-privileged` start the MCP server in an empty workspace and block forever. Load the workspace typedefs with core hidden and treat the workspace as module-backed only when Query has a served module function (`sourceModuleName`) or the module constructor `with`, matching the MCP tool loader. Empty workspace plus no `--env-privileged` now fails before starting the server.

The MCP integration coverage exercises the four intended modes: module without privileged, no module without privileged, no module with privileged, and module with privileged. Once workspace methods were actually invoked, module calls could include the existing tool-call log prefix before the string result, so the two module result assertions now verify that the returned content contains the module value instead of asserting exact output formatting.

Verification:
- git diff --check
- GOOS=linux GOARCH=amd64 go test -c ./cmd/dagger -o /tmp/cmd-dagger.test
- GOOS=linux GOARCH=amd64 go test -c ./core/integration -o /tmp/core-integration.test

A remote debug run before the CLI guard fix reproduced the hang with `--timeout=2m --test-verbose`: `TestWithoutModuleAndWithoutPrivilegedFails` was blocked in `hostDaggerExec(..., "mcp")`, waiting for the empty-workspace MCP process to exit. That confirmed the no-module guard needed to be fixed rather than weakening the test.

Signed-off-by: Solomon Hykes <[email protected]>

---------

Signed-off-by: Solomon Hykes <[email protected]>
tiborvass pushed a commit that referenced this pull request Apr 30, 2026
@shykes @tiborvass
mcp: restore workspace module methods in dagger mcp (#13030)
0e57993
* mcp: restore served module methods in static mode

Issue #13023 is a regression in how `dagger mcp` discovers methods for the
current workspace module. Static MCP method calling was still building its tool
set from objects installed in the env. After the workspace/module changes, the
workspace entrypoint methods are exposed on the served `Query` root instead of
always being materialized as installed env objects. That left static MCP with
an empty method list for workspace modules unless privileged mode also exposed
core `Query` methods.

Fix this by loading workspace module query fields from the served schema and
feeding them into the same static method-calling tool set as other callable
methods. The new `loadServedModuleQueryTools` path reads
`currentTypeDefs(hideCore: true)`, finds the module-owned `Query` object, maps
those functions back to the served GraphQL fields, and adds them as top-level
static call methods. The static MCP builtins now operate on a unified
`callMethods` set so module query methods, env-installed module methods, and
reachable object methods are selected and called through the same path.

Add integration coverage for the `dagger mcp` CLI command itself. The new tests
start `dagger mcp` over stdio and verify all four user-facing combinations:
workspace module without `--env-privileged`, no module without
`--env-privileged`, no module with `--env-privileged`, and workspace module
with `--env-privileged`.

Signed-off-by: Solomon Hykes <[email protected]>

* mcp: pass hideCore as an optional arg

The first `TestMCP` cloud run showed that the new workspace method loader was
calling `currentTypeDefs` with the wrong input type for `hideCore`.

That field is declared as `dagql.Optional[dagql.Boolean]`, but the loader was
passing a plain `dagql.Boolean`. That caused `dagger mcp` to fail during tool
loading before the MCP server finished starting, which made the integration
cases fail with `transport closed` and the wrong CLI error.

Wrap the value with `dagql.Opt(...)` so the selector matches the schema's input
shape.

Signed-off-by: Solomon Hykes <[email protected]>

* mcp: load workspace methods from live schema

`dagger mcp` in static tool mode was building the callable top-level method set from the environment dependency schema. That schema is useful for installed modules, reachable object methods, builtins, and other environment-backed behavior, but it does not represent the live workspace `Query` root after the current module has been served as an entrypoint. As a result, workspace functions such as `greeting` disappeared from `ListMethods`; privileged mode could still show core `Query` fields, which made the bug look like a filtering issue even though the actual problem was schema selection.

Split the schema sources used by `MCP.Tools`: load served workspace `Query` methods from `CurrentDagqlServer(ctx)`, and keep the env-backed schema from `m.env.Self().deps.Schema(ctx)` for module tools, reachable object methods, and builtins. The tool closures produced for served query methods retain the same live server they were built from, so `CallMethod` executes against the schema that exposed the workspace entrypoint method.

The same no-module path exposed another stale assumption in `dagger mcp`: `initializeWorkspace` always returns a `moduleDef`, even when no workspace module exists, so the old `modDef == nil` check never fired. That let `dagger mcp` without `--env-privileged` start the MCP server in an empty workspace and block forever. Load the workspace typedefs with core hidden and treat the workspace as module-backed only when Query has a served module function (`sourceModuleName`) or the module constructor `with`, matching the MCP tool loader. Empty workspace plus no `--env-privileged` now fails before starting the server.

The MCP integration coverage exercises the four intended modes: module without privileged, no module without privileged, no module with privileged, and module with privileged. Once workspace methods were actually invoked, module calls could include the existing tool-call log prefix before the string result, so the two module result assertions now verify that the returned content contains the module value instead of asserting exact output formatting.

Verification:
- git diff --check
- GOOS=linux GOARCH=amd64 go test -c ./cmd/dagger -o /tmp/cmd-dagger.test
- GOOS=linux GOARCH=amd64 go test -c ./core/integration -o /tmp/core-integration.test

A remote debug run before the CLI guard fix reproduced the hang with `--timeout=2m --test-verbose`: `TestWithoutModuleAndWithoutPrivilegedFails` was blocked in `hostDaggerExec(..., "mcp")`, waiting for the empty-workspace MCP process to exit. That confirmed the no-module guard needed to be fixed rather than weakening the test.

Signed-off-by: Solomon Hykes <[email protected]>

---------

Signed-off-by: Solomon Hykes <[email protected]>
(cherry picked from commit 092168c)
Signed-off-by: Tibor Vass <[email protected]>
tiborvass pushed a commit that referenced this pull request Apr 30, 2026
@shykes @tiborvass
mcp: restore workspace module methods in dagger mcp (#13030)
104a5ec
* mcp: restore served module methods in static mode

Issue #13023 is a regression in how `dagger mcp` discovers methods for the
current workspace module. Static MCP method calling was still building its tool
set from objects installed in the env. After the workspace/module changes, the
workspace entrypoint methods are exposed on the served `Query` root instead of
always being materialized as installed env objects. That left static MCP with
an empty method list for workspace modules unless privileged mode also exposed
core `Query` methods.

Fix this by loading workspace module query fields from the served schema and
feeding them into the same static method-calling tool set as other callable
methods. The new `loadServedModuleQueryTools` path reads
`currentTypeDefs(hideCore: true)`, finds the module-owned `Query` object, maps
those functions back to the served GraphQL fields, and adds them as top-level
static call methods. The static MCP builtins now operate on a unified
`callMethods` set so module query methods, env-installed module methods, and
reachable object methods are selected and called through the same path.

Add integration coverage for the `dagger mcp` CLI command itself. The new tests
start `dagger mcp` over stdio and verify all four user-facing combinations:
workspace module without `--env-privileged`, no module without
`--env-privileged`, no module with `--env-privileged`, and workspace module
with `--env-privileged`.

Signed-off-by: Solomon Hykes <[email protected]>

* mcp: pass hideCore as an optional arg

The first `TestMCP` cloud run showed that the new workspace method loader was
calling `currentTypeDefs` with the wrong input type for `hideCore`.

That field is declared as `dagql.Optional[dagql.Boolean]`, but the loader was
passing a plain `dagql.Boolean`. That caused `dagger mcp` to fail during tool
loading before the MCP server finished starting, which made the integration
cases fail with `transport closed` and the wrong CLI error.

Wrap the value with `dagql.Opt(...)` so the selector matches the schema's input
shape.

Signed-off-by: Solomon Hykes <[email protected]>

* mcp: load workspace methods from live schema

`dagger mcp` in static tool mode was building the callable top-level method set from the environment dependency schema. That schema is useful for installed modules, reachable object methods, builtins, and other environment-backed behavior, but it does not represent the live workspace `Query` root after the current module has been served as an entrypoint. As a result, workspace functions such as `greeting` disappeared from `ListMethods`; privileged mode could still show core `Query` fields, which made the bug look like a filtering issue even though the actual problem was schema selection.

Split the schema sources used by `MCP.Tools`: load served workspace `Query` methods from `CurrentDagqlServer(ctx)`, and keep the env-backed schema from `m.env.Self().deps.Schema(ctx)` for module tools, reachable object methods, and builtins. The tool closures produced for served query methods retain the same live server they were built from, so `CallMethod` executes against the schema that exposed the workspace entrypoint method.

The same no-module path exposed another stale assumption in `dagger mcp`: `initializeWorkspace` always returns a `moduleDef`, even when no workspace module exists, so the old `modDef == nil` check never fired. That let `dagger mcp` without `--env-privileged` start the MCP server in an empty workspace and block forever. Load the workspace typedefs with core hidden and treat the workspace as module-backed only when Query has a served module function (`sourceModuleName`) or the module constructor `with`, matching the MCP tool loader. Empty workspace plus no `--env-privileged` now fails before starting the server.

The MCP integration coverage exercises the four intended modes: module without privileged, no module without privileged, no module with privileged, and module with privileged. Once workspace methods were actually invoked, module calls could include the existing tool-call log prefix before the string result, so the two module result assertions now verify that the returned content contains the module value instead of asserting exact output formatting.

Verification:
- git diff --check
- GOOS=linux GOARCH=amd64 go test -c ./cmd/dagger -o /tmp/cmd-dagger.test
- GOOS=linux GOARCH=amd64 go test -c ./core/integration -o /tmp/core-integration.test

A remote debug run before the CLI guard fix reproduced the hang with `--timeout=2m --test-verbose`: `TestWithoutModuleAndWithoutPrivilegedFails` was blocked in `hostDaggerExec(..., "mcp")`, waiting for the empty-workspace MCP process to exit. That confirmed the no-module guard needed to be fixed rather than weakening the test.

Signed-off-by: Solomon Hykes <[email protected]>

---------

Signed-off-by: Solomon Hykes <[email protected]>
(cherry picked from commit 092168c)
Signed-off-by: Tibor Vass <[email protected]>
tiborvass pushed a commit that referenced this pull request May 2, 2026
@shykes @tiborvass
mcp: restore workspace module methods in dagger mcp (#13030)
9f4f131
* mcp: restore served module methods in static mode

Issue #13023 is a regression in how `dagger mcp` discovers methods for the
current workspace module. Static MCP method calling was still building its tool
set from objects installed in the env. After the workspace/module changes, the
workspace entrypoint methods are exposed on the served `Query` root instead of
always being materialized as installed env objects. That left static MCP with
an empty method list for workspace modules unless privileged mode also exposed
core `Query` methods.

Fix this by loading workspace module query fields from the served schema and
feeding them into the same static method-calling tool set as other callable
methods. The new `loadServedModuleQueryTools` path reads
`currentTypeDefs(hideCore: true)`, finds the module-owned `Query` object, maps
those functions back to the served GraphQL fields, and adds them as top-level
static call methods. The static MCP builtins now operate on a unified
`callMethods` set so module query methods, env-installed module methods, and
reachable object methods are selected and called through the same path.

Add integration coverage for the `dagger mcp` CLI command itself. The new tests
start `dagger mcp` over stdio and verify all four user-facing combinations:
workspace module without `--env-privileged`, no module without
`--env-privileged`, no module with `--env-privileged`, and workspace module
with `--env-privileged`.

Signed-off-by: Solomon Hykes <[email protected]>

* mcp: pass hideCore as an optional arg

The first `TestMCP` cloud run showed that the new workspace method loader was
calling `currentTypeDefs` with the wrong input type for `hideCore`.

That field is declared as `dagql.Optional[dagql.Boolean]`, but the loader was
passing a plain `dagql.Boolean`. That caused `dagger mcp` to fail during tool
loading before the MCP server finished starting, which made the integration
cases fail with `transport closed` and the wrong CLI error.

Wrap the value with `dagql.Opt(...)` so the selector matches the schema's input
shape.

Signed-off-by: Solomon Hykes <[email protected]>

* mcp: load workspace methods from live schema

`dagger mcp` in static tool mode was building the callable top-level method set from the environment dependency schema. That schema is useful for installed modules, reachable object methods, builtins, and other environment-backed behavior, but it does not represent the live workspace `Query` root after the current module has been served as an entrypoint. As a result, workspace functions such as `greeting` disappeared from `ListMethods`; privileged mode could still show core `Query` fields, which made the bug look like a filtering issue even though the actual problem was schema selection.

Split the schema sources used by `MCP.Tools`: load served workspace `Query` methods from `CurrentDagqlServer(ctx)`, and keep the env-backed schema from `m.env.Self().deps.Schema(ctx)` for module tools, reachable object methods, and builtins. The tool closures produced for served query methods retain the same live server they were built from, so `CallMethod` executes against the schema that exposed the workspace entrypoint method.

The same no-module path exposed another stale assumption in `dagger mcp`: `initializeWorkspace` always returns a `moduleDef`, even when no workspace module exists, so the old `modDef == nil` check never fired. That let `dagger mcp` without `--env-privileged` start the MCP server in an empty workspace and block forever. Load the workspace typedefs with core hidden and treat the workspace as module-backed only when Query has a served module function (`sourceModuleName`) or the module constructor `with`, matching the MCP tool loader. Empty workspace plus no `--env-privileged` now fails before starting the server.

The MCP integration coverage exercises the four intended modes: module without privileged, no module without privileged, no module with privileged, and module with privileged. Once workspace methods were actually invoked, module calls could include the existing tool-call log prefix before the string result, so the two module result assertions now verify that the returned content contains the module value instead of asserting exact output formatting.

Verification:
- git diff --check
- GOOS=linux GOARCH=amd64 go test -c ./cmd/dagger -o /tmp/cmd-dagger.test
- GOOS=linux GOARCH=amd64 go test -c ./core/integration -o /tmp/core-integration.test

A remote debug run before the CLI guard fix reproduced the hang with `--timeout=2m --test-verbose`: `TestWithoutModuleAndWithoutPrivilegedFails` was blocked in `hostDaggerExec(..., "mcp")`, waiting for the empty-workspace MCP process to exit. That confirmed the no-module guard needed to be fixed rather than weakening the test.

Signed-off-by: Solomon Hykes <[email protected]>

---------

Signed-off-by: Solomon Hykes <[email protected]>
(cherry picked from commit 092168c)
Signed-off-by: Tibor Vass <[email protected]>
tiborvass pushed a commit that referenced this pull request May 4, 2026
@shykes @tiborvass
mcp: restore workspace module methods in dagger mcp (#13030)
62eb84a
* mcp: restore served module methods in static mode

Issue #13023 is a regression in how `dagger mcp` discovers methods for the
current workspace module. Static MCP method calling was still building its tool
set from objects installed in the env. After the workspace/module changes, the
workspace entrypoint methods are exposed on the served `Query` root instead of
always being materialized as installed env objects. That left static MCP with
an empty method list for workspace modules unless privileged mode also exposed
core `Query` methods.

Fix this by loading workspace module query fields from the served schema and
feeding them into the same static method-calling tool set as other callable
methods. The new `loadServedModuleQueryTools` path reads
`currentTypeDefs(hideCore: true)`, finds the module-owned `Query` object, maps
those functions back to the served GraphQL fields, and adds them as top-level
static call methods. The static MCP builtins now operate on a unified
`callMethods` set so module query methods, env-installed module methods, and
reachable object methods are selected and called through the same path.

Add integration coverage for the `dagger mcp` CLI command itself. The new tests
start `dagger mcp` over stdio and verify all four user-facing combinations:
workspace module without `--env-privileged`, no module without
`--env-privileged`, no module with `--env-privileged`, and workspace module
with `--env-privileged`.

Signed-off-by: Solomon Hykes <[email protected]>

* mcp: pass hideCore as an optional arg

The first `TestMCP` cloud run showed that the new workspace method loader was
calling `currentTypeDefs` with the wrong input type for `hideCore`.

That field is declared as `dagql.Optional[dagql.Boolean]`, but the loader was
passing a plain `dagql.Boolean`. That caused `dagger mcp` to fail during tool
loading before the MCP server finished starting, which made the integration
cases fail with `transport closed` and the wrong CLI error.

Wrap the value with `dagql.Opt(...)` so the selector matches the schema's input
shape.

Signed-off-by: Solomon Hykes <[email protected]>

* mcp: load workspace methods from live schema

`dagger mcp` in static tool mode was building the callable top-level method set from the environment dependency schema. That schema is useful for installed modules, reachable object methods, builtins, and other environment-backed behavior, but it does not represent the live workspace `Query` root after the current module has been served as an entrypoint. As a result, workspace functions such as `greeting` disappeared from `ListMethods`; privileged mode could still show core `Query` fields, which made the bug look like a filtering issue even though the actual problem was schema selection.

Split the schema sources used by `MCP.Tools`: load served workspace `Query` methods from `CurrentDagqlServer(ctx)`, and keep the env-backed schema from `m.env.Self().deps.Schema(ctx)` for module tools, reachable object methods, and builtins. The tool closures produced for served query methods retain the same live server they were built from, so `CallMethod` executes against the schema that exposed the workspace entrypoint method.

The same no-module path exposed another stale assumption in `dagger mcp`: `initializeWorkspace` always returns a `moduleDef`, even when no workspace module exists, so the old `modDef == nil` check never fired. That let `dagger mcp` without `--env-privileged` start the MCP server in an empty workspace and block forever. Load the workspace typedefs with core hidden and treat the workspace as module-backed only when Query has a served module function (`sourceModuleName`) or the module constructor `with`, matching the MCP tool loader. Empty workspace plus no `--env-privileged` now fails before starting the server.

The MCP integration coverage exercises the four intended modes: module without privileged, no module without privileged, no module with privileged, and module with privileged. Once workspace methods were actually invoked, module calls could include the existing tool-call log prefix before the string result, so the two module result assertions now verify that the returned content contains the module value instead of asserting exact output formatting.

Verification:
- git diff --check
- GOOS=linux GOARCH=amd64 go test -c ./cmd/dagger -o /tmp/cmd-dagger.test
- GOOS=linux GOARCH=amd64 go test -c ./core/integration -o /tmp/core-integration.test

A remote debug run before the CLI guard fix reproduced the hang with `--timeout=2m --test-verbose`: `TestWithoutModuleAndWithoutPrivilegedFails` was blocked in `hostDaggerExec(..., "mcp")`, waiting for the empty-workspace MCP process to exit. That confirmed the no-module guard needed to be fixed rather than weakening the test.

Signed-off-by: Solomon Hykes <[email protected]>

---------

Signed-off-by: Solomon Hykes <[email protected]>
(cherry picked from commit 092168c)
Signed-off-by: Tibor Vass <[email protected]>
@tiborvass tiborvass mentioned this pull request May 4, 2026
chore: prep for v0.20.7 #13069
Merged
@BrewTestBot BrewTestBot mentioned this pull request May 4, 2026
dagger 0.20.7 Homebrew/homebrew-core#280811
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vito vito vito approved these changes
@grouville grouville Awaiting requested review from grouville grouville was automatically assigned from dagger/maintainers

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

dagger mcp does not expose current module functions in 0.20.6

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@shykes @vito
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.