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.

chg: make mcp available for free users (#5023)

teo377e8b6a6e0f
diff --git a/Cargo.lock b/Cargo.lock
index f4bb569ece..5225417abe 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -8716,7 +8716,6 @@ dependencies = [
"readonly_pool",
"redis",
"rmcp",
- "roles_and_permissions",
"search_service_client",
"secretsmanager_client",
"serde_json",
diff --git a/apps/docs/AI/mcp/overview.mdx b/apps/docs/AI/mcp/overview.mdx
index 88e22d03d5..6e793e501a 100644
--- a/apps/docs/AI/mcp/overview.mdx
+++ b/apps/docs/AI/mcp/overview.mdx
@@ -11,6 +11,7 @@ https://mcp-server.macro.com/mcp
```
The server is remote; no local process is required. Authentication happens through Macro's OAuth flow when the client connects.
+MCP access is available on every Macro plan, including Free.
## Claude Code
diff --git a/apps/web/src/features/paywall/PaywallComponent.tsx b/apps/web/src/features/paywall/PaywallComponent.tsx
index 59104ab2bd..2b52d0ffe3 100644
--- a/apps/web/src/features/paywall/PaywallComponent.tsx
+++ b/apps/web/src/features/paywall/PaywallComponent.tsx
@@ -23,7 +23,6 @@ const PAYWALL_PREMIUM_FEATURES = [
'All agents',
'All models',
'No watermark',
- 'MCP access',
'AI projections',
'Multiple email inboxes',
'Calls',
diff --git a/apps/web/src/features/settings/Billing.tsx b/apps/web/src/features/settings/Billing.tsx
index e5d9ee88c3..9274262ce1 100644
--- a/apps/web/src/features/settings/Billing.tsx
+++ b/apps/web/src/features/settings/Billing.tsx
@@ -13,12 +13,11 @@ import { createMemo, For, Match, Show, Switch } from 'solid-js';
import { SettingsCard, SettingsPage, SettingsSection } from './primitives';
const BILLING_PLAN_FEATURES: Record<PlanTier, string[]> = {
- free: ['Access to Haiku', '5 GB storage'],
+ free: ['Access to Haiku', 'MCP access', '5 GB storage'],
premium: [
'All agents',
'All models',
'No watermark',
- 'MCP access',
'AI projections',
'Multiple email inboxes',
'Calls',
diff --git a/services/mcp_service/Cargo.toml b/services/mcp_service/Cargo.toml
index 1ada57b745..2c84831e3b 100644
--- a/services/mcp_service/Cargo.toml
+++ b/services/mcp_service/Cargo.toml
@@ -56,7 +56,6 @@ notification = { path = "../../crates/notification", features = ["ai_tool"] }
prompt = { path = "../../crates/prompt" }
readonly_pool = { path = "../../crates/readonly_pool" }
redis = { workspace = true, features = ["aio", "tokio-comp"] }
-roles_and_permissions = { path = "../../crates/roles_and_permissions" }
rmcp = { workspace = true, features = ["transport-streamable-http-server"] }
search_service_client = { path = "../../crates/search_service_client" }
secretsmanager_client = { path = "../../crates/secretsmanager_client" }
diff --git a/services/mcp_service/src/context.rs b/services/mcp_service/src/context.rs
index 37919f7b29..1202b00ba3 100644
--- a/services/mcp_service/src/context.rs
+++ b/services/mcp_service/src/context.rs
@@ -38,9 +38,6 @@ use mcp_auth_proxy::{
};
use notification::domain::service::{NotificationReaderService, PlatformArnConfig};
use notification::outbound::repository::DbNotificationRepository;
-use roles_and_permissions::{
- domain::service::UserRolesAndPermissionsServiceImpl, outbound::pgpool::MacroDB,
-};
use search_service_client::SearchServiceClient;
use secretsmanager_client::LocalOrRemoteSecret;
use soup::domain::service::SoupImpl;
@@ -56,7 +53,6 @@ pub struct McpContext {
pub tool_context: ToolServiceContext,
pub auth_proxy: McpAuthProxyServiceImpl<RedisInflightAuth>,
pub mcp_public_host: String,
- pub user_roles_and_permissions_service: UserRolesAndPermissionsServiceImpl<MacroDB, MacroDB>,
}
pub async fn build_context(config: &Config) -> anyhow::Result<McpContext> {
@@ -111,16 +107,11 @@ pub async fn build_context(config: &Config) -> anyhow::Result<McpContext> {
.context("MCP_PUBLIC_URL has no host")?
.to_owned();
- let roles_repository = MacroDB::new(db.clone());
- let user_roles_and_permissions_service =
- UserRolesAndPermissionsServiceImpl::new(roles_repository.clone(), roles_repository);
-
Ok(McpContext {
jwt_args,
tool_context,
auth_proxy,
mcp_public_host,
- user_roles_and_permissions_service,
})
}
diff --git a/services/mcp_service/src/main.rs b/services/mcp_service/src/main.rs
index 2856e42c2b..218b9560d4 100644
--- a/services/mcp_service/src/main.rs
+++ b/services/mcp_service/src/main.rs
@@ -42,7 +42,6 @@ async fn main() -> anyhow::Result<()> {
Ok(AuthenticatedToolService::new(
tools.toolset,
context.tool_context.clone(),
- context.user_roles_and_permissions_service.clone(),
item_base_url.clone(),
))
},
diff --git a/services/mcp_service/src/tool_service.rs b/services/mcp_service/src/tool_service.rs
index f7e5c803e5..7ee25aa648 100644
--- a/services/mcp_service/src/tool_service.rs
+++ b/services/mcp_service/src/tool_service.rs
@@ -6,7 +6,6 @@ use rmcp::{
Content, ListToolsResult, PaginatedRequestParams, ServerCapabilities, ServerInfo, Tool,
},
};
-use roles_and_permissions::domain::port::UserRolesAndPermissionsService;
use std::sync::Arc;
/// MCP server handler that extracts authenticated user identity from HTTP
@@ -15,31 +14,25 @@ use std::sync::Arc;
dead_code,
reason = "fields used via ServerHandler trait impl dispatched by rmcp"
)]
-pub struct AuthenticatedToolService<Context, RolesService> {
+pub struct AuthenticatedToolService<Context> {
toolset: Arc<AsyncToolCollection<Context>>,
context: Context,
- user_roles_and_permissions_service: RolesService,
/// Base URL of the Macro web app used to build links to Macro items in MCP
/// responses (e.g. `https://macro.com`). Comes from the `APP_BASE_URL`
/// environment variable.
item_base_url: String,
}
-impl<Context, RolesService> AuthenticatedToolService<Context, RolesService>
-where
- RolesService: UserRolesAndPermissionsService,
-{
+impl<Context> AuthenticatedToolService<Context> {
/// Creates a new authenticated tool service.
pub fn new(
toolset: Arc<AsyncToolCollection<Context>>,
context: Context,
- user_roles_and_permissions_service: RolesService,
item_base_url: String,
) -> Self {
Self {
toolset,
context,
- user_roles_and_permissions_service,
item_base_url,
}
}
@@ -68,41 +61,14 @@ where
rmcp::ErrorData::internal_error("missing user identity — is auth configured?", None)
})
}
-
- async fn require_paid_subscription(
- &self,
- user_id: &MacroUserIdStr<'_>,
- ) -> Result<(), rmcp::ErrorData> {
- let roles = self
- .user_roles_and_permissions_service
- .get_user_roles(user_id)
- .await
- .map_err(|e| {
- tracing::error!(error=?e, "failed to check user subscription roles for MCP access");
- rmcp::ErrorData::internal_error("failed to check subscription", None)
- })?;
-
- let is_paid = roles.iter().any(|role| role.is_paid_subscription());
-
- if !is_paid {
- return Err(rmcp::ErrorData::new(
- rmcp::model::ErrorCode::INVALID_REQUEST,
- "MCP access requires a paid subscription",
- None,
- ));
- }
-
- Ok(())
- }
}
#[cfg(test)]
mod test;
-impl<Context, RolesService> ServerHandler for AuthenticatedToolService<Context, RolesService>
+impl<Context> ServerHandler for AuthenticatedToolService<Context>
where
Context: Clone + Send + Sync + 'static,
- RolesService: UserRolesAndPermissionsService,
{
fn get_info(&self) -> ServerInfo {
let mut info = ServerInfo::new(ServerCapabilities::builder().enable_tools().build());
@@ -132,8 +98,7 @@ where
_request: Option<PaginatedRequestParams>,
context: rmcp::service::RequestContext<rmcp::RoleServer>,
) -> Result<ListToolsResult, rmcp::ErrorData> {
- let user_id = Self::authenticated_user_id(&context.extensions)?;
- self.require_paid_subscription(&user_id).await?;
+ Self::authenticated_user_id(&context.extensions)?;
Ok(ListToolsResult {
tools: self.tool_definitions(),
@@ -147,7 +112,6 @@ where
context: rmcp::service::RequestContext<rmcp::RoleServer>,
) -> Result<rmcp::model::CallToolResult, rmcp::ErrorData> {
let user_id = Self::authenticated_user_id(&context.extensions)?;
- self.require_paid_subscription(&user_id).await?;
let request_context = RequestContext::new(user_id);
diff --git a/services/mcp_service/src/tool_service/test.rs b/services/mcp_service/src/tool_service/test.rs
index 6a12280fb4..6158160f1a 100644
--- a/services/mcp_service/src/tool_service/test.rs
+++ b/services/mcp_service/src/tool_service/test.rs
@@ -1,22 +1,11 @@
use super::*;
use ai_toolset::AsyncToolCollection;
use rmcp::{handler::server::ServerHandler, model::ErrorCode};
-use roles_and_permissions::{
- domain::service::UserRolesAndPermissionsServiceImpl, outbound::pgpool::MacroDB,
-};
-use sqlx::postgres::PgPoolOptions;
-
-type TestRolesService = UserRolesAndPermissionsServiceImpl<MacroDB, MacroDB>;
-
-fn empty_service() -> AuthenticatedToolService<(), TestRolesService> {
- let db = PgPoolOptions::new()
- .connect_lazy("postgres://localhost/unused")
- .expect("lazy pool creation should not fail");
- let roles_repository = MacroDB::new(db);
+
+fn empty_service() -> AuthenticatedToolService<()> {
AuthenticatedToolService::new(
Arc::new(AsyncToolCollection::new()),
(),
- UserRolesAndPermissionsServiceImpl::new(roles_repository.clone(), roles_repository),
"https://macro.com".to_owned(),
)
}
@@ -105,19 +94,16 @@ fn authenticated_user_id_is_read_from_http_request_parts() {
let mut extensions = rmcp::model::Extensions::new();
extensions.insert(parts);
- let user_id =
- AuthenticatedToolService::<(), TestRolesService>::authenticated_user_id(&extensions)
- .unwrap();
+ let user_id = AuthenticatedToolService::<()>::authenticated_user_id(&extensions).unwrap();
assert_eq!(user_id, expected_user_id);
}
#[test]
fn authenticated_user_id_requires_request_parts() {
- let error = AuthenticatedToolService::<(), TestRolesService>::authenticated_user_id(
- &rmcp::model::Extensions::new(),
- )
- .expect_err("missing request parts should fail auth extraction");
+ let error =
+ AuthenticatedToolService::<()>::authenticated_user_id(&rmcp::model::Extensions::new())
+ .expect_err("missing request parts should fail auth extraction");
assert_eq!(error.code, ErrorCode::INTERNAL_ERROR);
assert_eq!(error.message, "missing user identity — is auth configured?");
@@ -129,9 +115,8 @@ fn authenticated_user_id_requires_user_extension_inside_request_parts() {
let mut extensions = rmcp::model::Extensions::new();
extensions.insert(parts);
- let error =
- AuthenticatedToolService::<(), TestRolesService>::authenticated_user_id(&extensions)
- .expect_err("missing user id should fail auth extraction");
+ let error = AuthenticatedToolService::<()>::authenticated_user_id(&extensions)
+ .expect_err("missing user id should fail auth extraction");
assert_eq!(error.code, ErrorCode::INTERNAL_ERROR);
assert_eq!(error.message, "missing user identity — is auth configured?");