Skip to main content
Glama

create_audience

Set up a new Mailchimp audience by specifying name, sender email, and company details.

Instructions

Create a new audience/list. Requires name, sender email, and company name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
from_emailYes
companyYes
permission_reminderNoYou signed up on our website.
from_nameNo
countryNoUS

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The actual handler function for the create_audience tool. Creates a new Mailchimp audience/list via POST /lists with name, sender email, company, permission reminder, and campaign defaults.
    @mcp.tool()
    async def create_audience(
        name: str,
        from_email: str,
        company: str,
        permission_reminder: str = "You signed up on our website.",
        from_name: str = "",
        country: str = "US",
    ) -> str:
        """Create a new audience/list. Requires name, sender email, and company name."""
        mc = get_client()
        body = {
            "name": name,
            "permission_reminder": permission_reminder,
            "email_type_option": True,
            "contact": {
                "company": company,
                "address1": "",
                "city": "",
                "state": "",
                "zip": "",
                "country": country,
            },
            "campaign_defaults": {
                "from_name": from_name or company,
                "from_email": from_email,
                "subject": "",
                "language": "en",
            },
        }
        a = await mc.post("/lists", json=body)
        return _fmt({
            "id": a["id"],
            "name": a.get("name", ""),
            "message": "Audience created.",
        })
  • The @mcp.tool() decorator registers create_audience as an MCP tool.
    @mcp.tool()
    async def create_audience(
  • get_client() creates/returns the singleton MailchimpClient used by create_audience to make the API call.
    def get_client() -> MailchimpClient:
        global _client
        if _client is None:
            api_key = os.environ.get("MAILCHIMP_API_KEY", "")
            if not api_key or "-" not in api_key:
                raise ValueError(
                    "MAILCHIMP_API_KEY environment variable required. "
                    "Format: xxxxxxxxxx-usXX "
                    "(get yours at https://mailchimp.com/account/api)"
                )
            _client = MailchimpClient(api_key)
        return _client
  • _fmt() utility used by create_audience to format the response as indented JSON.
    def _fmt(data: Any) -> str:
        """Format response data as indented JSON string."""
        return json.dumps(data, indent=2, default=str)
  • MailchimpClient class provides the post() method that create_audience uses to make the POST /lists API request.
    class MailchimpClient:
        """Lightweight async client for the Mailchimp Marketing API v3."""
    
        def __init__(self, api_key: str):
            if "-" not in api_key:
                raise ValueError(
                    "Invalid API key format. Expected: xxxxxxxxxx-usXX"
                )
            self.api_key = api_key
            self.dc = api_key.rsplit("-", 1)[-1]
            self.base_url = f"https://{self.dc}.api.mailchimp.com/3.0"
            self._client = httpx.AsyncClient(
                base_url=self.base_url,
                auth=("apikey", api_key),
                headers={"Accept": "application/json"},
                timeout=30.0,
            )
    
        @staticmethod
        def subscriber_hash(email: str) -> str:
            """MD5 hash of lowercase email — Mailchimp's subscriber identifier."""
            return hashlib.md5(email.lower().strip().encode()).hexdigest()
    
        async def _request(self, method: str, path: str, **kwargs: Any) -> Any:
            resp = await self._client.request(method, path, **kwargs)
            if resp.status_code == 204:
                return {"success": True}
            try:
                data = resp.json()
            except Exception:
                data = {"title": "Parse Error", "detail": resp.text}
            if resp.status_code >= 400:
                raise MailchimpError(
                    data.get("title", "Unknown Error"),
                    data.get("detail", "No details provided"),
                    resp.status_code,
                )
            return data
    
        async def get(self, path: str, params: dict[str, Any] | None = None) -> Any:
            return await self._request("GET", path, params=params)
    
        async def post(self, path: str, json: dict[str, Any] | None = None) -> Any:
            return await self._request("POST", path, json=json or {})
    
        async def patch(self, path: str, json: dict[str, Any]) -> Any:
            return await self._request("PATCH", path, json=json)
    
        async def put(self, path: str, json: dict[str, Any]) -> Any:
            return await self._request("PUT", path, json=json)
    
        async def delete(self, path: str) -> Any:
            return await self._request("DELETE", path)
    
        async def close(self) -> None:
            await self._client.aclose()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description should disclose behavioral traits. It only states requirements without describing side effects, idempotency, or success/failure behavior. Minimal transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with purpose. Efficient but slightly underspecified. Could include more information without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 6 parameters, 3 of which are required, and the presence of an output schema, the description is too minimal. It omits optional parameter details and any constraints or usage context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%. Description adds value for required parameters (name, from_email, company) but does not explain optional parameters (permission_reminder, from_name, country) or any parameter semantics beyond naming.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states action and resource: 'Create a new audience/list.' Distinguishes from sibling tools like update_audience. However, does not explicitly contrast with similar creation tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Only lists required parameters but provides no guidance on when to use this tool versus alternatives such as update_audience or list_audiences. No exclusions or prerequisites mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/AlexlaGuardia/mcp-mailchimp'

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