Skip to main content
Glama
therealjohn

Microsoft Teams MCP Server

by therealjohn

send-notification

Send Markdown-formatted notifications to Microsoft Teams channels to alert users about project updates or important messages.

Instructions

Send a notification message to the user. Supports markdown formatting for messages. Use backticks for code blocks and inline code. Use square brackets for placeholders.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYes
projectYes

Implementation Reference

  • The primary tool handler decorated with @server.call_tool(), which handles calls to 'send-notification'. It validates arguments, checks environment variables, acquires an authentication token, and invokes the send_notification helper to deliver the message.
    @server.call_tool()
    async def handle_call_tool(
        name: str, arguments: dict | None
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        if name != TOOL_NAME:
            raise ValueError(f"Unknown tool: {name}")
    
        if not arguments:
            raise ValueError("Missing arguments")
    
        message = arguments.get("message")
        project = arguments.get("project")
    
        if not message or not project:
            raise ValueError("Missing message or project")
    
        env_vars, missing_vars = validate_environment_variables()
        
        if missing_vars:
            return [
                types.TextContent(
                    type="text",
                    text=f"Missing required environment variables: {', '.join(missing_vars)}"
                )
            ]
        
        try:
            access_token, error = await get_auth_token(
                env_vars["MICROSOFT_APP_ID"], 
                env_vars["MICROSOFT_APP_PASSWORD"], 
                env_vars["MICROSOFT_APP_TENANT_ID"]
            )
            
            if error:
                return [
                    types.TextContent(
                        type="text",
                        text=f"Authentication failed: {error}"
                    )
                ]
            
            success, error_msg = await send_notification(
                env_vars["BOT_ENDPOINT"],
                access_token,
                env_vars["EMAIL"],
                message,
                project
            )
            
            if not success:
                return [
                    types.TextContent(
                        type="text",
                        text=f"Failed to send notification: {error_msg}"
                    )
                ]
            
            return [
                types.TextContent(
                    type="text",
                    text=f"Sent notification message for project '{project}' with content: {message}",
                )
            ]
                    
        except Exception as e:
            return [
                types.TextContent(
                    type="text",
                    text=f"Error sending notification: {str(e)}"
                )
            ]
  • The @server.list_tools() handler that registers the 'send-notification' tool, providing its name (TOOL_NAME), description, and input schema.
    @server.list_tools()
    async def handle_list_tools() -> list[types.Tool]:
        return [
            types.Tool(
                name=TOOL_NAME,
                description="Send a notification message to the user. Supports markdown formatting for messages. Use backticks for code blocks and inline code. Use square brackets for placeholders.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "message": {"type": "string"},
                        "project": {"type": "string"},
                    },
                    "required": ["message", "project"],
                },
            )
        ]
  • The JSON schema defining the input parameters for the 'send-notification' tool: message (string, required) and project (string, required).
    inputSchema={
        "type": "object",
        "properties": {
            "message": {"type": "string"},
            "project": {"type": "string"},
        },
        "required": ["message", "project"],
    },
  • Core helper function send_notification that sends an HTTP POST request to the configured bot endpoint with the notification payload, using the provided access token.
    async def send_notification(
        bot_endpoint: str, 
        access_token: str, 
        email: Optional[str], 
        message: str, 
        project: str
    ) -> Tuple[bool, Optional[str]]:
        """
        Send notification to the Teams bot endpoint.
        
        Args:
            bot_endpoint: The bot endpoint URL
            access_token: Authentication token
            email: User email (optional)
            message: Notification message
            project: Project name
        
        Returns:
            Tuple containing (success, error_message)
        """
        try:        
            payload = {
                "email": email,
                "message": message,
                "project": project,
            }
            
            headers = {
                "Authorization": f"Bearer {access_token}",
                "Content-Type": "application/json"
            }
            
            async with aiohttp.ClientSession() as session:
                async with session.post(bot_endpoint, json=payload, headers=headers) as response:
                    if response.status >= 400:
                        response_text = await response.text()
                        return False, f"HTTP {response.status} - {response_text}"
                    
                    return True, None
                    
        except Exception as e:
            return False, str(e)
  • Helper function get_auth_token that acquires an MSAL access token using client credentials flow for authenticating with Microsoft services.
    async def get_auth_token(app_id: str, app_password: str, tenant_id: str) -> Tuple[Optional[str], Optional[str]]:
        """
        Get authentication token using MSAL client credentials flow.
        
        Args:
            app_id: The application ID
            app_password: The application password/secret
            tenant_id: The tenant ID
            
        Returns:
            Tuple containing (access_token, error_message)
        """
        try:
            app = msal.ConfidentialClientApplication(
                client_id=app_id,
                client_credential=app_password,
                authority=f"https://login.microsoftonline.com/{tenant_id}"
            )
            
            scopes = [f"{app_id}/.default"]
            
            result = app.acquire_token_for_client(scopes)
            
            if "access_token" not in result:
                error_msg = result.get("error_description", "Failed to acquire token")
                return None, error_msg
                
            return result["access_token"], None
        except Exception as e:
            return None, str(e)
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions markdown formatting support, which adds some behavioral context about message handling. However, it lacks details on delivery mechanisms, user targeting, error handling, or response format, leaving significant gaps for a notification-sending tool.

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?

The description is concise and front-loaded with the core purpose. The formatting details are relevant but could be more efficiently integrated. No wasted sentences, though it could be slightly more structured for clarity.

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 no annotations, 0% schema coverage, and no output schema, the description is incomplete. It covers message formatting but misses parameter explanations, behavioral traits like delivery guarantees, and expected outcomes. For a tool with two required parameters, this is inadequate.

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%, so the description must compensate. It does not explain the 'message' or 'project' parameters at all—no semantics, examples, or constraints. The formatting advice applies generally to messages but doesn't clarify parameter roles or usage.

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?

The description clearly states the tool's purpose: 'Send a notification message to the user.' It specifies the action (send) and resource (notification message), though it doesn't distinguish from siblings since none exist. The mention of markdown formatting adds specificity about message capabilities.

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?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or exclusions. It only describes formatting features (markdown, backticks, square brackets) without contextual usage advice. Since there are no sibling tools, this is less critical but still a gap.

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/therealjohn/microsoft-teams-mcp'

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