Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(mcp): surface Macro mention and citation rules to MCP clients (#4163)

Eric Hayes310b32460079
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index bb9be3196c..ef9eeeb4b6 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -7236,6 +7236,7 @@ dependencies = [
"macro_user_id",
"mcp_auth_proxy",
"notification",
+ "prompt",
"properties",
"readonly_pool",
"redis",
diff --git a/rust/cloud-storage/mcp_service/Cargo.toml b/rust/cloud-storage/mcp_service/Cargo.toml
index 8bd1328946..a63f73022a 100644
--- a/rust/cloud-storage/mcp_service/Cargo.toml
+++ b/rust/cloud-storage/mcp_service/Cargo.toml
@@ -41,6 +41,7 @@ macro_middleware = { path = "../macro_middleware", default-features = false, fea
] }
macro_user_id = { path = "../macro_user_id" }
notification = { path = "../notification", features = ["ai_tool"] }
+prompt = { path = "../prompt" }
properties = { path = "../properties", features = ["ai_tools"] }
readonly_pool = { path = "../readonly_pool" }
redis = { workspace = true, features = ["aio", "tokio-comp"] }
diff --git a/rust/cloud-storage/mcp_service/src/tool_service.rs b/rust/cloud-storage/mcp_service/src/tool_service.rs
index 955597bd2a..9c8433eae2 100644
--- a/rust/cloud-storage/mcp_service/src/tool_service.rs
+++ b/rust/cloud-storage/mcp_service/src/tool_service.rs
@@ -104,14 +104,14 @@ where
.with_description(
"Search, read, and create content across documents, emails, and messages in Macro.",
);
- info.instructions = Some(
+ info.instructions = Some(format!(
"This server provides tools for interacting with a user's Macro workspace. \
Use ContentSearch and NameSearch to find entities. \
Use ReadContent, ReadMetadata, and ReadThread to read them. \
Use CreateDocument to create new documents. \
- Use ListEntities to browse recent items."
- .into(),
- );
+ Use ListEntities to browse recent items.\n\n{}",
+ prompt::MCP_INSTRUCTIONS,
+ ));
info
}
diff --git a/rust/cloud-storage/prompt/src/lib.rs b/rust/cloud-storage/prompt/src/lib.rs
index 601a3aa8c8..8441ed5ada 100644
--- a/rust/cloud-storage/prompt/src/lib.rs
+++ b/rust/cloud-storage/prompt/src/lib.rs
@@ -29,3 +29,14 @@ pub static BASE_PROMPT: ComposedPrompt = tone::PROMPT
/// The tool-enabled prompt: [`BASE_PROMPT`] with the tool use instructions
/// appended.
pub static TOOL_USE_PROMPT: ComposedPrompt = BASE_PROMPT.compose(&tool_usage::PROMPT);
+
+/// Instructions surfaced to external MCP clients via the server `instructions`
+/// field. Carries the formatting/correctness rules Macro features depend on —
+/// mentions, citations, do-not rules, and Macro terms — so that AI used through
+/// MCP produces valid Macro mentions and citations. Deliberately omits chat
+/// tone/style and tool-use instructions, which belong to the host client, not
+/// to Macro.
+pub static MCP_INSTRUCTIONS: ComposedPrompt = mentions::PROMPT
+ .compose(&citations::PROMPT)
+ .compose(&do_not::PROMPT)
+ .compose(&about_macro::PROMPT);
diff --git a/rust/cloud-storage/prompt/src/mentions.rs b/rust/cloud-storage/prompt/src/mentions.rs
index 7c7c734c6e..50f31afc13 100644
--- a/rust/cloud-storage/prompt/src/mentions.rs
+++ b/rust/cloud-storage/prompt/src/mentions.rs
@@ -22,7 +22,7 @@ When a tool returns both a channel id and a channel message id, link the specifi
### Example Response
If no inline or node ids are present:
-“See the document for details<m-document-mention>{“documentId”:”6a2b138d-dfbe-439a-a78b-282471a1e165”,”documentName”:””,”blockName”:”md”,”blockParams”:{}}</m-document-mention>.”
+"See the document for details<m-document-mention>{"documentId":"6a2b138d-dfbe-439a-a78b-282471a1e165","documentName":"","blockName":"md","blockParams":{}}</m-document-mention>."
"##;
static INTENT: &str = "Entities and channel messages are referenced with correctly formatted \