Skip to content
Closed
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
3 changes: 3 additions & 0 deletions packages/sdk-python/src/qwen_code_sdk/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ def build_cli_arguments(options: QueryOptions) -> list[str]:
if options.allowed_tools:
args.extend(["--allowed-tools", ",".join(options.allowed_tools)])

if options.allowed_mcp_server_names:
args.extend(["--allowed-mcp-server-names", ",".join(options.allowed_mcp_server_names)])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] This line is 95 characters, exceeding the project's ruff line-length = 88 configured in pyproject.toml. This will fail ruff check.

Suggested change
args.extend(["--allowed-mcp-server-names", ",".join(options.allowed_mcp_server_names)])
args.extend(
["--allowed-mcp-server-names", ",".join(options.allowed_mcp_server_names)]
)

— qwen3.7-max via Qwen Code /review


if options.auth_type:
args.extend(["--auth-type", options.auth_type])

Expand Down
5 changes: 5 additions & 0 deletions packages/sdk-python/src/qwen_code_sdk/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class QueryOptionsDict(TypedDict, total=False):
timeout: TimeoutOptionsDict
mcp_servers: dict[str, dict[str, Any]]
stderr: Callable[[str], None]
allowed_mcp_server_names: list[str]


@dataclass
Expand All @@ -139,6 +140,7 @@ class QueryOptions:
timeout: TimeoutOptions = TimeoutOptions()
mcp_servers: dict[str, dict[str, Any]] | None = None
stderr: Callable[[str], None] | None = None
allowed_mcp_server_names: list[str] | None = None

@classmethod
def from_mapping(cls, value: Mapping[str, Any] | None) -> QueryOptions:
Expand Down Expand Up @@ -183,6 +185,9 @@ def from_mapping(cls, value: Mapping[str, Any] | None) -> QueryOptions:
Callable[[str], None] | None,
_as_optional_callable(data, "stderr"),
),
allowed_mcp_server_names=_as_optional_str_list(
data, "allowed_mcp_server_names"
),
)


Expand Down
1 change: 1 addition & 0 deletions packages/sdk-typescript/src/query/createQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function query({
coreTools: options.coreTools,
excludeTools: options.excludeTools,
allowedTools: options.allowedTools,
allowedMcpServerNames: options.allowedMcpServerNames,
authType: options.authType,
includePartialMessages: options.includePartialMessages,
resume: options.resume,
Expand Down
10 changes: 10 additions & 0 deletions packages/sdk-typescript/src/transport/ProcessTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,16 @@ export class ProcessTransport implements Transport {
args.push('--allowed-tools', this.options.allowedTools.join(','));
}

if (
this.options.allowedMcpServerNames &&
this.options.allowedMcpServerNames.length > 0
) {
args.push(
'--allowed-mcp-server-names',
this.options.allowedMcpServerNames.join(','),
);
}

if (this.options.authType) {
args.push('--auth-type', this.options.authType);
}
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-typescript/src/types/queryOptionsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,6 @@ export const QueryOptionsSchema = z
resume: z.string().optional(),
sessionId: z.string().optional(),
timeout: TimeoutConfigSchema.optional(),
allowedMcpServerNames: z.array(z.string()).optional(),
})
.strict();
11 changes: 11 additions & 0 deletions packages/sdk-typescript/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export type TransportOptions = {
* When resume is provided, this should match the resume ID.
*/
sessionId?: string;
/**
* Allowed MCP server names. When provided, only these MCP servers
* will be available. Equivalent to CLI's `--allowed-mcp-server-names`.
*/
allowedMcpServerNames?: string[];
};

export interface QuerySystemPromptPreset {
Expand Down Expand Up @@ -503,4 +508,10 @@ export interface QueryOptions {
*/
streamClose?: number;
};

/**
* Allowed MCP server names. When provided, only these MCP servers
* will be available. Equivalent to CLI's `--allowed-mcp-server-names`.
*/
allowedMcpServerNames?: string[];
}
Loading