Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(mcp): expose branch name to mcp tool (#2522)
Will Hutchinsone899919e8753
diff --git a/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts b/js/app/packages/service-clients/service-cognition/generated/tools/schemas.tsindex e508d8dc26..e6b44aff3e 100644--- a/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts+++ b/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts@@ -521,6 +521,7 @@ export const ReadMetadata = zexport const ReadMetadataResponse = z.object({documentMetadata: z.object({+ branchName: z.union([z.string(), z.null()]).optional(),branchedFromId: z.union([z.string(), z.null()]).optional(),branchedFromVersionId: z.union([z.number().int(), z.null()]).optional(),createdAt: zdiff --git a/js/app/packages/service-clients/service-cognition/generated/tools/types.ts b/js/app/packages/service-clients/service-cognition/generated/tools/types.tsindex b1ecf8f474..deec8e4c6c 100644--- a/js/app/packages/service-clients/service-cognition/generated/tools/types.ts+++ b/js/app/packages/service-clients/service-cognition/generated/tools/types.ts@@ -977,6 +977,10 @@ export interface ReadMetadataResponse {* The metadata of the document*/documentMetadata: {+ /**+ * If the document is a "task" the branch name of the document will be provided.+ */+ branchName?: string | null;/*** The id of the document this document branched from*/diff --git a/rust/cloud-storage/documents/src/inbound/toolset/read_metadata.rs b/rust/cloud-storage/documents/src/inbound/toolset/read_metadata.rsindex df3a8cc839..61865dd0dd 100644--- a/rust/cloud-storage/documents/src/inbound/toolset/read_metadata.rs+++ b/rust/cloud-storage/documents/src/inbound/toolset/read_metadata.rs@@ -14,11 +14,22 @@ use uuid::Uuid;use super::DocumentToolContext;+#[derive(Debug, Serialize, JsonSchema)]+#[serde(rename_all = "camelCase")]+pub struct ReadDocumentMetadata {+ /// The document metadata+ #[serde(flatten)]+ document: DocumentMetadata,+ /// If the document is a "task" the branch name of the document will be provided.+ #[serde(skip_serializing_if = "Option::is_none")]+ branch_name: Option<String>,+}+#[derive(Debug, Serialize, JsonSchema)]#[serde(rename_all = "camelCase")]pub struct ReadMetadataResponse {/// The metadata of the document- pub document_metadata: DocumentMetadata,+ pub document_metadata: ReadDocumentMetadata,/// The users level of access to the documentpub user_access_level: AccessLevel,}@@ -64,15 +75,42 @@ wherelet result = service_context.service- .get_document(entity_access_receipt)+ .get_document(entity_access_receipt.clone()).await.map_err(|e| ToolCallError {description: "unable to get the document metadata".to_string(),internal_error: e.into(),})?;+ let branch_name = if let Some(sub_type) = result.document_metadata.sub_type {+ match sub_type {+ document_sub_type::DocumentSubType::Task => {+ let short_id = service_context+ .service+ .get_short_id(entity_access_receipt)+ .await+ .map_err(|e| ToolCallError {+ description: "unable to get the short id".to_string(),+ internal_error: e.into(),+ })?;++ let name = result.document_metadata.document_name.clone();+ let slugified_name = name.replace(" ", "-").to_lowercase();++ Some(format!("macro-{short_id}-{slugified_name}"))+ }+ }+ } else {+ None+ };++ let document_metadata = ReadDocumentMetadata {+ document: result.document_metadata,+ branch_name,+ };+Ok(ReadMetadataResponse {- document_metadata: result.document_metadata,+ document_metadata,user_access_level: result.user_access_level,})}diff --git a/rust/cloud-storage/models_permissions/src/share_permission/access_level.rs b/rust/cloud-storage/models_permissions/src/share_permission/access_level.rsindex a1b4d8c92c..f7cd6038c5 100644--- a/rust/cloud-storage/models_permissions/src/share_permission/access_level.rs+++ b/rust/cloud-storage/models_permissions/src/share_permission/access_level.rs@@ -28,13 +28,13 @@ pub enum AccessLevel {Owner,}-#[derive(Debug)]+#[derive(Debug, Clone)]pub struct ViewAccessLevel;-#[derive(Debug)]+#[derive(Debug, Clone)]pub struct CommentAccessLevel;-#[derive(Debug)]+#[derive(Debug, Clone)]pub struct EditAccessLevel;-#[derive(Debug)]+#[derive(Debug, Clone)]pub struct OwnerAccessLevel;#[cfg(test)]