Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions auth/oauth_callback_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ def run_server():
port=self.port,
log_level="warning",
access_log=False,
# Match FastMCP's own uvicorn config: uvicorn's "auto"
# default resolves to the deprecated legacy-websockets
# implementation whenever `websockets` is installed.
ws="websockets-sansio",
)
self.server = uvicorn.Server(config)
asyncio.run(self.server.serve())
Expand Down
19 changes: 15 additions & 4 deletions core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ def _build_oauth() -> OAuth:
return OAuth(token_storage=storage)


def _coerce_cli_value(value: str) -> Any:
"""Parse a CLI value as JSON, but keep the raw text whenever it is a string.

``max_results=5`` still becomes ``int(5)``, while a quoted value such as
``query='"grow therapy"'`` keeps its quotes instead of being unwrapped into
``grow therapy``, which would break Gmail phrase matching.
"""
try:
parsed = json.loads(value)
except json.JSONDecodeError:
return value
return value if isinstance(parsed, str) else parsed


async def _list_tools(url: str) -> None:
"""Connect, authenticate once, and print available tools."""
try:
Expand Down Expand Up @@ -97,10 +111,7 @@ async def _call_tool(url: str, tool_name: str, raw_args: list[str]) -> None:
print(f"Error: argument '{arg}' must be in key=value form", file=sys.stderr)
sys.exit(1)
k, v = arg.split("=", 1)
try:
kwargs[k] = json.loads(v)
except json.JSONDecodeError:
kwargs[k] = v
kwargs[k] = _coerce_cli_value(v)

async with Client(url, auth=_build_oauth()) as client:
result = await client.call_tool(tool_name, kwargs)
Expand Down
9 changes: 8 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,14 @@ async def _run_dual() -> None:
if http_available:
app = server.http_app(path="/mcp")
config = uvicorn.Config(
app, host=http_host, port=http_port, log_level="warning"
app,
host=http_host,
port=http_port,
log_level="warning",
# Match FastMCP's own uvicorn config: uvicorn's "auto"
# default resolves to the deprecated legacy-websockets
# implementation whenever `websockets` is installed.
ws="websockets-sansio",
)
http_srv = uvicorn.Server(config)
http_task = asyncio.create_task(http_srv.serve())
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ test = [
"opentelemetry-sdk>=1.20.0",
"opentelemetry-exporter-otlp>=1.20.0",
"requests>=2.32.3",
"httpx2>=2.0.0",
]
release = [
"tomlkit>=0.13.3",
Expand All @@ -96,6 +97,7 @@ dev = [
"opentelemetry-sdk>=1.20.0",
"opentelemetry-exporter-otlp>=1.20.0",
"requests>=2.32.3",
"httpx2>=2.0.0",
"ruff>=0.15.22,<0.16",
"tomlkit>=0.13.3",
"twine>=5.0.0",
Expand All @@ -115,6 +117,7 @@ test = [
"opentelemetry-sdk>=1.20.0",
"opentelemetry-exporter-otlp>=1.20.0",
"requests>=2.32.3",
"httpx2>=2.0.0",
]
release = [
"tomlkit>=0.13.3",
Expand All @@ -127,6 +130,7 @@ dev = [
"opentelemetry-sdk>=1.20.0",
"opentelemetry-exporter-otlp>=1.20.0",
"requests>=2.32.3",
"httpx2>=2.0.0",
"ruff>=0.15.22,<0.16",
"tomlkit>=0.13.3",
"twine>=5.0.0",
Expand Down
39 changes: 39 additions & 0 deletions tests/core/test_cli_value_coercion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Tests for workspace-cli key=value argument coercion."""

import pytest

from core.cli import _coerce_cli_value


@pytest.mark.parametrize(
"raw, expected",
[
("is:unread", "is:unread"),
("gmail drive calendar", "gmail drive calendar"),
# Quotes must survive for Gmail phrase queries.
('"grow therapy"', '"grow therapy"'),
('"grow therapy" newer_than:15mo', '"grow therapy" newer_than:15mo'),
("2026/04/16", "2026/04/16"),
("", ""),
],
)
def test_strings_are_preserved_verbatim(raw, expected):
assert _coerce_cli_value(raw) == expected


@pytest.mark.parametrize(
"raw, expected",
[
("3", 3),
("-2", -2),
("3.5", 3.5),
("true", True),
("false", False),
("null", None),
('["a", "b"]', ["a", "b"]),
('[["a", "b"]]', [["a", "b"]]),
('{"k": 1}', {"k": 1}),
],
)
def test_json_like_values_are_coerced(raw, expected):
assert _coerce_cli_value(raw) == expected
52 changes: 49 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading