Skip to content

Facebook MCP server for automating posts, comment moderation, insights, and sentiment filtering.

Python

add more insight tools

Hagai Henec104290e211
diff --git a/manager.py b/manager.py
index dbc7e1e..6e8007c 100644
--- a/manager.py
+++ b/manager.py
@@ -45,3 +45,39 @@ class Manager:
"post_reactions_haha_total", "post_reactions_sorry_total", "post_reactions_anger_total",
]
return self.api.get_bulk_insights(post_id, metrics)
+
+ def get_post_impressions(self, post_id: str) -> dict[str, Any]:
+ return self.api.get_insight(post_id, "post_impressions")
+
+ def get_post_impressions_unique(self, post_id: str) -> dict[str, Any]:
+ return self.api.get_insight(post_id, "post_impressions_unique")
+
+ def get_post_impressions_paid(self, post_id: str) -> dict[str, Any]:
+ return self.api.get_insight(post_id, "post_impressions_paid")
+
+ def get_post_impressions_organic(self, post_id: str) -> dict[str, Any]:
+ return self.api.get_insight(post_id, "post_impressions_organic")
+
+ def get_post_engaged_users(self, post_id: str) -> dict[str, Any]:
+ return self.api.get_insight(post_id, "post_engaged_users")
+
+ def get_post_clicks(self, post_id: str) -> dict[str, Any]:
+ return self.api.get_insight(post_id, "post_clicks")
+
+ def get_post_reactions_like_total(self, post_id: str) -> dict[str, Any]:
+ return self.api.get_insight(post_id, "post_reactions_like_total")
+
+ def get_post_reactions_love_total(self, post_id: str) -> dict[str, Any]:
+ return self.api.get_insight(post_id, "post_reactions_love_total")
+
+ def get_post_reactions_wow_total(self, post_id: str) -> dict[str, Any]:
+ return self.api.get_insight(post_id, "post_reactions_wow_total")
+
+ def get_post_reactions_haha_total(self, post_id: str) -> dict[str, Any]:
+ return self.api.get_insight(post_id, "post_reactions_haha_total")
+
+ def get_post_reactions_sorry_total(self, post_id: str) -> dict[str, Any]:
+ return self.api.get_insight(post_id, "post_reactions_sorry_total")
+
+ def get_post_reactions_anger_total(self, post_id: str) -> dict[str, Any]:
+ return self.api.get_insight(post_id, "post_reactions_anger_total")
diff --git a/server.py b/server.py
index fe54aed..3caa8a0 100644
--- a/server.py
+++ b/server.py
@@ -2,7 +2,7 @@ from mcp.server.fastmcp import FastMCP
from manager import Manager
from typing import Any
-mcp = FastMCP("Demo")
+mcp = FastMCP("FacebookMCP")
manager = Manager()
@mcp.tool()
@@ -91,4 +91,100 @@ def get_post_insights(post_id: str) -> dict[str, Any]:
Input: post_id (str)
Output: dict with multiple metrics and their values
"""
- return manager.get_post_insights(post_id)
\ No newline at end of file
+ return manager.get_post_insights(post_id)
+
+def get_post_impressions(post_id: str) -> dict[str, Any]:
+ """Fetch total impressions of a post.
+ Input: post_id (str)
+ Output: dict with total impression count
+ """
+ return manager.get_post_impressions(post_id)
+
+def get_post_impressions_unique(post_id: str) -> dict[str, Any]:
+ """Fetch unique impressions of a post.
+ Input: post_id (str)
+ Output: dict with unique impression count
+ """
+ return manager.get_post_impressions_unique(post_id)
+
+def get_post_impressions_paid(post_id: str) -> dict[str, Any]:
+ """Fetch paid impressions of a post.
+ Input: post_id (str)
+ Output: dict with paid impression count
+ """
+ return manager.get_post_impressions_paid(post_id)
+
+def get_post_impressions_organic(post_id: str) -> dict[str, Any]:
+ """Fetch organic impressions of a post.
+ Input: post_id (str)
+ Output: dict with organic impression count
+ """
+ return manager.get_post_impressions_organic(post_id)
+
+def get_post_engaged_users(post_id: str) -> dict[str, Any]:
+ """Fetch number of engaged users.
+ Input: post_id (str)
+ Output: dict with engagement count
+ """
+ return manager.get_post_engaged_users(post_id)
+
+def get_post_clicks(post_id: str) -> dict[str, Any]:
+ """Fetch number of post clicks.
+ Input: post_id (str)
+ Output: dict with click count
+ """
+ return manager.get_post_clicks(post_id)
+
+def get_post_reactions_like_total(post_id: str) -> dict[str, Any]:
+ """Fetch number of 'Like' reactions.
+ Input: post_id (str)
+ Output: dict with like count
+ """
+ return manager.get_post_reactions_like_total(post_id)
+
+def get_post_reactions_love_total(post_id: str) -> dict[str, Any]:
+ """Fetch number of 'Love' reactions.
+ Input: post_id (str)
+ Output: dict with love count
+ """
+ return manager.get_post_reactions_love_total(post_id)
+
+def get_post_reactions_wow_total(post_id: str) -> dict[str, Any]:
+ """Fetch number of 'Wow' reactions.
+ Input: post_id (str)
+ Output: dict with wow count
+ """
+ return manager.get_post_reactions_wow_total(post_id)
+
+def get_post_reactions_haha_total(post_id: str) -> dict[str, Any]:
+ """Fetch number of 'Haha' reactions.
+ Input: post_id (str)
+ Output: dict with haha count
+ """
+ return manager.get_post_reactions_haha_total(post_id)
+
+def get_post_reactions_sorry_total(post_id: str) -> dict[str, Any]:
+ """Fetch number of 'Sorry' reactions.
+ Input: post_id (str)
+ Output: dict with sorry count
+ """
+ return manager.get_post_reactions_sorry_total(post_id)
+
+def get_post_reactions_anger_total(post_id: str) -> dict[str, Any]:
+ """Fetch number of 'Anger' reactions.
+ Input: post_id (str)
+ Output: dict with anger count
+ """
+ return manager.get_post_reactions_anger_total(post_id)