Skip to main content
Glama
ag2-mcp-servers

WhatsApp Business API MCP Server

main.py20.9 kB
# generated by fastapi-codegen: # filename: openapi.yaml # timestamp: 2025-06-29T12:14:34+00:00 import argparse import json import os from typing import * from typing import Optional, Union from autogen.mcp.mcp_proxy import MCPProxy from autogen.mcp.mcp_proxy.security import BaseSecurity, HTTPBasic, HTTPBearer from fastapi import Path, UploadFile from models import ( ApplicationSettings, BackupSettingsRequestBody, BackupSettingsResponse, BusinessProfile, CheckContactRequestBody, CheckContactResponse, CreateGroupRequestBody, CreateUserRequestBody, DetailedUserResponse, EnableTwoStepRequestBody, GetBusinessProfileResponse, GetMediaProvidersResponse, GetProfileAboutResponse, GetProfilePhotoResponse, GroupAdminRequestBody, GroupInviteResponse, GroupResponse, GroupsResponse, LoginAdminRequestBody, MarkMessageAsReadRequestBody, MessageResponse, MetricsGetResponse, ProfileAbout, RegisterAccountRequestBody, RemoveGroupParticipantRequestBody, RequestCodeRequestBody, RequestCodeResponse, Response, RestoreSettingsRequestBody, SendMessageRequestBody, SetShardsRequestBody, SettingsApplicationMediaProvidersPostRequest, StatsAppGetResponse, StatsDbGetResponse, SupportGetResponse, UpdateGroupInfoRequestBody, UpdateUserRequestBody, UploadMediaResponse, UserLoginResponse, UserResponse, WebhookEvent, ) app = MCPProxy( contact={'x-twitter': 'WhatsApp'}, description='See https://developers.facebook.com/docs/whatsapp', title='WhatsApp Business API', version='1.0', servers=[{'url': 'http://whatsapp.local'}, {'url': 'http://example.com/v1'}], ) @app.post( '/account', tags=['user_account_management', 'user_management'], security=[ HTTPBearer(name="None"), ], ) def request_code(body: RequestCodeRequestBody): """ Request-Code """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/account/shards', tags=['user_account_management', 'user_management'], security=[ HTTPBearer(name="None"), ], ) def set_shards(body: SetShardsRequestBody): """ Set-Shards """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/account/verify', tags=['user_account_management', 'user_management'], security=[ HTTPBearer(name="None"), ], ) def register_account(body: RegisterAccountRequestBody): """ Register-Account """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/certificates/external', tags=['certificate_management'], security=[ HTTPBearer(name="None"), ], ) def upload_certificate(): """ Upload-Certificate """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/certificates/external/ca', tags=['certificate_management'], security=[ HTTPBearer(name="None"), ], ) def download_ca_certificate(): """ Download-CA-Certificate """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete( '/certificates/webhooks/ca', tags=['certificate_management'], security=[ HTTPBearer(name="None"), ], ) def delete_webhook_ca_certificate(): """ Delete Webhook CA Certificate """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/certificates/webhooks/ca', tags=['certificate_management'], security=[ HTTPBearer(name="None"), ], ) def download_webhook_ca_certificate(): """ Download Webhook CA Certificate """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/certificates/webhooks/ca', tags=['certificate_management'], security=[ HTTPBearer(name="None"), ], ) def upload_webhook_ca_certificate(): """ Upload Webhook CA Certificate """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/contacts', tags=['user_account_management', 'user_management'], security=[ HTTPBearer(name="None"), ], ) def check_contact(body: CheckContactRequestBody): """ Check-Contact """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/groups', tags=['group_management', 'group_member_management'], security=[ HTTPBearer(name="None"), ], ) def get_all_groups(): """ Get-All-Groups """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/groups', tags=['group_management'], security=[ HTTPBearer(name="None"), ], ) def create_group(body: CreateGroupRequestBody): """ Create-Group """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/groups/{GroupId}', tags=['group_management', 'group_member_management', 'group_invitation_management'], security=[ HTTPBearer(name="None"), ], ) def get_group_info(group_id: str = Path(..., alias='GroupId')): """ Get-Group-Info """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.put( '/groups/{GroupId}', tags=['group_management', 'group_member_management'], security=[ HTTPBearer(name="None"), ], ) def update_group_info( group_id: str = Path(..., alias='GroupId'), body: UpdateGroupInfoRequestBody = ... ): """ Update-Group-Info """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete( '/groups/{GroupId}/admins', tags=['group_member_management', 'group_management'], security=[ HTTPBearer(name="None"), ], ) def demote_group_admin( group_id: str = Path(..., alias='GroupId'), body: GroupAdminRequestBody = ... ): """ Demote-Group-Admin """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.patch( '/groups/{GroupId}/admins', tags=['group_management', 'group_member_management'], security=[ HTTPBearer(name="None"), ], ) def promote_to_group_admin( group_id: str = Path(..., alias='GroupId'), body: GroupAdminRequestBody = ... ): """ Promote-To-Group-Admin """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete( '/groups/{GroupId}/icon', tags=['group_icon_management', 'group_management'], security=[ HTTPBearer(name="None"), ], ) def delete_group_icon( group_id: str = Path(..., alias='GroupId'), file: UploadFile = ... ): """ Delete-Group-Icon """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/groups/{GroupId}/icon', tags=['group_icon_management', 'group_management'], security=[ HTTPBearer(name="None"), ], ) def get_group_icon_binary(group_id: str = Path(..., alias='GroupId')): """ Get-Group-Icon-Binary """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/groups/{GroupId}/icon', tags=['group_icon_management', 'group_management'], security=[ HTTPBearer(name="None"), ], ) def set_group_icon(group_id: str = Path(..., alias='GroupId'), file: UploadFile = ...): """ Set-Group-Icon """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete( '/groups/{GroupId}/invite', tags=['group_invitation_management', 'group_management', 'group_member_management'], security=[ HTTPBearer(name="None"), ], ) def delete_group_invite(group_id: str = Path(..., alias='GroupId')): """ Delete-Group-Invite """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/groups/{GroupId}/invite', tags=['group_invitation_management', 'group_management'], security=[ HTTPBearer(name="None"), ], ) def get_group_invite(group_id: str = Path(..., alias='GroupId')): """ Get-Group-Invite """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/groups/{GroupId}/leave', tags=['group_management', 'group_member_management'], security=[ HTTPBearer(name="None"), ], ) def leave_group(group_id: str = Path(..., alias='GroupId')): """ Leave-Group """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete( '/groups/{GroupId}/participants', tags=['group_management', 'group_member_management'], security=[ HTTPBearer(name="None"), ], ) def remove_group_participant( group_id: str = Path(..., alias='GroupId'), body: RemoveGroupParticipantRequestBody = ..., ): """ Remove-Group-Participant """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/health', tags=['system_health_check'], security=[ HTTPBearer(name="None"), ], ) def check_health(): """ Check-Health """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/media', tags=['media_management'], security=[ HTTPBearer(name="None"), ], ) def upload_media(): """ Upload-Media """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete( '/media/{MediaId}', tags=['media_management'], security=[ HTTPBearer(name="None"), ], ) def delete_media(media_id: str = Path(..., alias='MediaId')): """ Delete-Media """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/media/{MediaId}', tags=['media_management'], security=[ HTTPBearer(name="None"), ], ) def download_media(media_id: str = Path(..., alias='MediaId')): """ Download-Media """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/messages', tags=['message_management'], security=[ HTTPBearer(name="None"), ], ) def send_message(body: SendMessageRequestBody): """ Send-Message """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.put( '/messages/{MessageID}', tags=['message_management'], security=[ HTTPBearer(name="None"), ], ) def mark_message_as_read( message_i_d: str = Path(..., alias='MessageID'), body: MarkMessageAsReadRequestBody = ..., ): """ Mark-Message-As-Read """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/metrics', tags=['application_statistics', 'system_health_check'], security=[ HTTPBearer(name="None"), ], ) def get_metrics(format: Optional[str] = None): """ Get-Metrics (since v2.21.3) """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete( '/settings/account/two-step', tags=[ 'user_account_management', 'two_factor_authentication', 'two_step_verification', ], security=[ HTTPBearer(name="None"), ], ) def disable_two_step(): """ Disable-Two-Step """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/settings/account/two-step', tags=[ 'two_factor_authentication', 'two_step_verification', 'user_account_management', ], security=[ HTTPBearer(name="None"), ], ) def enable_two_step(body: EnableTwoStepRequestBody): """ Enable-Two-Step """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete( '/settings/application', tags=['application_settings_management', 'user_account_management'], security=[ HTTPBearer(name="None"), ], ) def reset_application_settings(): """ Reset-Application-Settings """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/settings/application', tags=[ 'application_settings_management', 'user_account_management', 'settings_backup_and_restore', ], security=[ HTTPBearer(name="None"), ], ) def get_application_settings(): """ Get-Application-Settings """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/settings/application', description=""" If a field is not present in the request, no change is made to that setting. For example, if on_call_pager is not sent with the request, the existing configuration for on_call_pager is unchanged. """, tags=['application_settings_management', 'user_account_management'], security=[ HTTPBearer(name="None"), ], ) def update_application_settings(body: ApplicationSettings): """ Update-Application-Settings """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/settings/application/media/providers', tags=['media_provider_management', 'media_management'], security=[ HTTPBearer(name="None"), ], ) def get_media_providers(): """ Get-Media-Providers """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/settings/application/media/providers', tags=['media_provider_management', 'application_settings_management'], security=[ HTTPBearer(name="None"), ], ) def update_media_providers(body: SettingsApplicationMediaProvidersPostRequest): """ Update-Media-Providers """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete( '/settings/application/media/providers/{ProviderName}', tags=['media_management', 'media_provider_management'], security=[ HTTPBearer(name="None"), ], ) def delete_media_providers(provider_name: str = Path(..., alias='ProviderName')): """ Delete-Media-Providers """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/settings/backup', tags=['application_settings_management', 'settings_backup_and_restore'], security=[ HTTPBearer(name="None"), ], ) def backup_settings(body: BackupSettingsRequestBody): """ Backup-Settings """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/settings/business/profile', tags=['business_profile_management'], security=[ HTTPBearer(name="None"), ], ) def get_business_profile(): """ Get-Business-Profile """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/settings/business/profile', tags=['business_profile_management'], security=[ HTTPBearer(name="None"), ], ) def update_business_profile(body: BusinessProfile): """ Update-Business-Profile """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/settings/profile/about', tags=['user_profile_management', 'user_account_management'], security=[ HTTPBearer(name="None"), ], ) def get_profile_about(): """ Get-Profile-About """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.patch( '/settings/profile/about', tags=['user_profile_management', 'user_account_management', 'user_management'], security=[ HTTPBearer(name="None"), ], ) def update_profile_about(body: ProfileAbout): """ Update-Profile-About """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete( '/settings/profile/photo', tags=['user_profile_management', 'user_account_management'], security=[ HTTPBearer(name="None"), ], ) def delete_profile_photo(): """ Delete-Profile-Photo """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/settings/profile/photo', tags=['user_profile_management'], security=[ HTTPBearer(name="None"), ], ) def get_profile_photo(format: Optional[str] = None): """ Get-Profile-Photo """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/settings/profile/photo', tags=['user_profile_management', 'user_account_management', 'user_management'], security=[ HTTPBearer(name="None"), ], ) def update_profile_photo(file: UploadFile): """ Update-Profile-Photo """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/settings/restore', tags=[ 'settings_backup_and_restore', 'application_settings_management', 'user_account_management', ], security=[ HTTPBearer(name="None"), ], ) def restore_settings(body: RestoreSettingsRequestBody): """ Restore-Settings """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/stats/app', tags=['application_statistics'], security=[ HTTPBearer(name="None"), ], ) def get_app_stats(format: Optional[str] = None): """ Get-App-Stats """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/stats/db', tags=['application_statistics', 'system_health_check'], security=[ HTTPBearer(name="None"), ], ) def get_db_stats(format: Optional[str] = None): """ Get-DB-Stats """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/support', tags=['user_management', 'user_account_management'], security=[ HTTPBearer(name="None"), ], ) def get_support_info(): """ Get-Support-Info """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/users', tags=['user_account_management', 'user_management'], security=[ HTTPBearer(name="None"), ], ) def create_user(body: CreateUserRequestBody): """ Create-User """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/users/login', tags=['user_account_management', 'user_management'], security=[ HTTPBasic(name="None"), ], ) def login_user(body: LoginAdminRequestBody = None): """ Login-User """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/users/logout', tags=['user_account_management', 'user_management'], security=[ HTTPBearer(name="None"), ], ) def logout_user(): """ Logout-User """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete( '/users/{UserUsername}', tags=['user_account_management', 'user_management'], security=[ HTTPBearer(name="None"), ], ) def delete_user(user_username: str = Path(..., alias='UserUsername')): """ Delete-User """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/users/{UserUsername}', tags=['user_account_management', 'user_management', 'user_profile_management'], security=[ HTTPBearer(name="None"), ], ) def get_user(user_username: str = Path(..., alias='UserUsername')): """ Get-User """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.put( '/users/{UserUsername}', tags=['user_account_management', 'user_profile_management', 'user_management'], security=[ HTTPBearer(name="None"), ], ) def update_user( user_username: str = Path(..., alias='UserUsername'), body: UpdateUserRequestBody = ..., ): """ Update-User """ raise RuntimeError("Should be patched by MCPProxy and never executed") if __name__ == "__main__": parser = argparse.ArgumentParser(description="MCP Server") parser.add_argument( "transport", choices=["stdio", "sse", "streamable-http"], help="Transport mode (stdio, sse or streamable-http)", ) args = parser.parse_args() if "CONFIG_PATH" in os.environ: config_path = os.environ["CONFIG_PATH"] app.load_configuration(config_path) if "CONFIG" in os.environ: config = os.environ["CONFIG"] app.load_configuration_from_string(config) if "SECURITY" in os.environ: security_params = BaseSecurity.parse_security_parameters_from_env( os.environ, ) app.set_security_params(security_params) mcp_settings = json.loads(os.environ.get("MCP_SETTINGS", "{}")) app.get_mcp(**mcp_settings).run(transport=args.transport)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ag2-mcp-servers/whatsapp-business-api'

If you have feedback or need assistance with the MCP directory API, please join our Discord server