fix(extension): 向MCP命令传递插件设置

This commit is contained in:
2026-09-02 18:23:32 +08:00
parent b16230ac4c
commit 09c1bdac21
4 changed files with 11 additions and 1 deletions
+1
View File
@@ -633,6 +633,7 @@ class PluginRuntime:
"command_id": _spec.command_id, "command_id": _spec.command_id,
"arguments": arguments, "arguments": arguments,
"context": context, "context": context,
"settings": settings,
"secrets": secret_values, "secrets": secret_values,
} }
}, },
@@ -71,8 +71,10 @@ def call_tool(request_id: int, params: dict[str, Any]) -> None:
envelope = arguments.get("_notesagent") or {} envelope = arguments.get("_notesagent") or {}
command_arguments = envelope.get("arguments") or {} command_arguments = envelope.get("arguments") or {}
context = envelope.get("context") or {} context = envelope.get("context") or {}
settings = envelope.get("settings") or {}
secrets = envelope.get("secrets") or {} secrets = envelope.get("secrets") or {}
message = command_arguments.get("message") or context.get("selection") or "" message = command_arguments.get("message") or context.get("selection") or ""
message = f"{settings.get('message_prefix', '')}{message}"
respond( respond(
request_id, request_id,
{ {
@@ -1,6 +1,10 @@
section_id: mcp-fixture.general section_id: mcp-fixture.general
schema_version: 1 schema_version: 1
fields: fields:
- key: message_prefix
label: Message Prefix
type: string
default: ""
- key: api_key - key: api_key
label: Fixture API Key label: Fixture API Key
type: secret type: secret
+4 -1
View File
@@ -415,6 +415,9 @@ def test_mcp_command_target_receives_scoped_context_and_declared_secret(
mcp_container.plugins.put_setting_secret( mcp_container.plugins.put_setting_secret(
"mcp-fixture", "api_key", "mcp-command-secret" "mcp-fixture", "api_key", "mcp-command-secret"
) )
mcp_container.plugins.update_settings(
"mcp-fixture", 1, {"message_prefix": "Fixture: "}
)
result = await mcp_container.plugins.execute_command( result = await mcp_container.plugins.execute_command(
"mcp-fixture.notify", "mcp-fixture.notify",
{}, {},
@@ -427,7 +430,7 @@ def test_mcp_command_target_receives_scoped_context_and_declared_secret(
assert result.effect.type == "notification" assert result.effect.type == "notification"
assert result.effect.payload == { assert result.effect.payload == {
"level": "success", "level": "success",
"message": "来自选区", "message": "Fixture: 来自选区",
"secret_configured": True, "secret_configured": True,
} }
assert "mcp-command-secret" not in repr( assert "mcp-command-secret" not in repr(