Meta Ads (Facebook/Instagram) MCP server for Claude, ChatGPT, Perplexity & Cursor — the Meta node of Pipeboard’s 5-platform family (+ Google, TikTok, Snap, Reddit). Hosted remote MCP, badged Meta Business Partner, free plan — no self-hosting required.
Python advertisingai-agentschatgptclaudefacebook-adsinstagram-adsmcpmeta-adsmodel-context-protocolpipeboard
Refactor Meta Ads MCP package structure and enhance API functionality
Yves Junqueirad3c8c23a1f69
diff --git a/meta_ads_mcp/__init__.py b/meta_ads_mcp/__init__.pyindex 6dad60d..3800004 100644--- a/meta_ads_mcp/__init__.py+++ b/meta_ads_mcp/__init__.py@@ -3,7 +3,7 @@__version__ = "0.1.0"# Import key functions to make them available at package level-from .meta_ads_generated import (+from .api import (get_ad_accounts,get_account_info,get_campaigns,@@ -18,4 +18,10 @@ from .meta_ads_generated import (get_insights,get_login_link,login_cli,-)\ No newline at end of file+ main, # Import main function for entry point+)++# Define a main function to be used as a package entry point+def entrypoint():+ """Main entry point for the package when invoked with uvx."""+ return main()\ No newline at end of filediff --git a/meta_ads_mcp/meta_ads_generated.py b/meta_ads_mcp/api.pysimilarity index 98%rename from meta_ads_mcp/meta_ads_generated.pyrename to meta_ads_mcp/api.pyindex ae8df4f..bb0055f 100644--- a/meta_ads_mcp/meta_ads_generated.py+++ b/meta_ads_mcp/api.py@@ -298,6 +298,9 @@ class AuthManager:except Exception as e:print(f"Error removing cached token: {e}")+ def clear_token(self) -> None:+ """Clear the current token and remove from cache"""+ self.invalidate_token()# Initialize auth managerauth_manager = AuthManager(META_APP_ID)@@ -1820,7 +1823,35 @@ def start_callback_server():return start_callback_server() # Recursive call with a new portraise e-if __name__ == "__main__":+def login_cli():+ """+ Command line entry point for just the login function.+ """+ # Set up command line arguments+ parser = argparse.ArgumentParser(description="Meta Ads Login Utility")+ parser.add_argument("--app-id", type=str, help="Meta App ID (Client ID) for authentication")+ parser.add_argument("--force-login", action="store_true", help="Force a new login even if a token exists")++ args = parser.parse_args()++ # Update app ID if provided+ if args.app_id:+ auth_manager.app_id = args.app_id++ if args.force_login:+ # Clear existing token+ auth_manager.clear_token()++ # Perform login+ login()++ return 0++def main():+ """+ Main entry point for the Meta Ads MCP server.+ This function handles command line arguments and runs the server.+ """# Set up command line argumentsparser = argparse.ArgumentParser(description="Meta Ads MCP Server")parser.add_argument("--login", action="store_true", help="Authenticate with Meta and store the token")@@ -1837,4 +1868,10 @@ if __name__ == "__main__":login()else:# Initialize and run the server- mcp_server.run(transport='stdio')\ No newline at end of file+ mcp_server.run(transport='stdio')++ return 0++# Modify the if __name__ block to use the main function+if __name__ == "__main__":+ main()\ No newline at end of filediff --git a/pyproject.toml b/pyproject.tomlindex aff969c..66f35fa 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -32,7 +32,8 @@ dependencies = ["Bug Tracker" = "https://github.com/nictuku/meta-ads-mcp/issues"[project.scripts]-meta-ads-login = "meta_ads_mcp.meta_ads_generated:login_cli"+meta-ads-mcp = "meta_ads_mcp:entrypoint"+meta-ads-login = "meta_ads_mcp.api:login_cli"[tool.hatch.build.targets.wheel]packages = ["meta_ads_mcp"]