Facebook MCP server for automating posts, comment moderation, insights, and sentiment filtering.
Python
feat: add scheduled posts and share/fan metrics
Hagai Hen8539dd5a404f
diff --git a/README.md b/README.mdindex 5065dd1..ec750e7 100644--- a/README.md+++ b/README.md@@ -45,6 +45,9 @@ This MCP provides a suite of AI-callable tools that connect directly to a Facebo| `post_image_to_facebook` | Post an image with a caption to the Facebook page. || `send_dm_to_user` | Send a direct message to a user. || `update_post` | Updates an existing post's message. |+| `schedule_post` | Schedule a post for future publication. |+| `get_page_fan_count` | Retrieve the total number of Page fans. |+| `get_post_share_count` | Get the number of shares on a post. |---diff --git a/facebook_api.py b/facebook_api.pyindex 6a86f86..198d63f 100644--- a/facebook_api.py+++ b/facebook_api.py@@ -52,4 +52,20 @@ class FacebookAPI:return self._request("POST", "me/messages", {}, json=payload)def update_post(self, post_id: str, new_message: str) -> dict[str, Any]:- return self._request("POST", f"{post_id}", {"message": new_message})\ No newline at end of file+ return self._request("POST", f"{post_id}", {"message": new_message})++ def schedule_post(self, message: str, publish_time: int) -> dict[str, Any]:+ params = {+ "message": message,+ "published": False,+ "scheduled_publish_time": publish_time,+ }+ return self._request("POST", f"{PAGE_ID}/feed", params)++ def get_page_fan_count(self) -> int:+ data = self._request("GET", f"{PAGE_ID}", {"fields": "fan_count"})+ return data.get("fan_count", 0)++ def get_post_share_count(self, post_id: str) -> int:+ data = self._request("GET", f"{post_id}", {"fields": "shares"})+ return data.get("shares", {}).get("count", 0)diff --git a/manager.py b/manager.pyindex c109705..a678e1c 100644--- a/manager.py+++ b/manager.py@@ -98,4 +98,13 @@ class Manager:return self.api.send_dm_to_user(user_id, message)def update_post(self, post_id: str, new_message: str) -> dict[str, Any]:- return self.api.update_post(post_id, new_message)\ No newline at end of file+ return self.api.update_post(post_id, new_message)++ def schedule_post(self, message: str, publish_time: int) -> dict[str, Any]:+ return self.api.schedule_post(message, publish_time)++ def get_page_fan_count(self) -> int:+ return self.api.get_page_fan_count()++ def get_post_share_count(self, post_id: str) -> int:+ return self.api.get_post_share_count(post_id)diff --git a/server.py b/server.pyindex 3fe13c3..5f3d70a 100644--- a/server.py+++ b/server.py@@ -219,4 +219,28 @@ def update_post(post_id: str, new_message: str) -> dict[str, Any]:Input: post_id (str), new_message (str)Output: dict of update result"""- return manager.update_post(post_id, new_message)\ No newline at end of file+ return manager.update_post(post_id, new_message)+def schedule_post(message: str, publish_time: int) -> dict[str, Any]:+ """Schedule a new post for future publishing.+ Input: message (str), publish_time (Unix timestamp)+ Output: dict with scheduled post info+ """+ return manager.schedule_post(message, publish_time)++def get_page_fan_count() -> int:+ """Get the Page's total fan/like count.+ Input: None+ Output: integer fan count+ """+ return manager.get_page_fan_count()++def get_post_share_count(post_id: str) -> int:+ """Get the number of shares for a post.+ Input: post_id (str)+ Output: integer share count+ """+ return manager.get_post_share_count(post_id)+