Skip to main content
Glama
abutbul

Gatherings MCP Server

by abutbul

add_expense

Record expenses for social events to track payments and calculate reimbursements between friends.

Instructions

Add an expense for a member

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gathering_idYesID of the gathering
member_nameYesName of the member who paid
amountYesAmount paid by the member

Implementation Reference

  • MCP tool schema for 'add_expense', defining input parameters: gathering_id (string), member_name (string), amount (number). Returned in listTools response.
    name: 'add_expense',
    description: 'Add an expense for a member',
    inputSchema: {
      type: 'object',
      properties: {
        gathering_id: {
          type: 'string',
          description: 'ID of the gathering',
        },
        member_name: {
          type: 'string',
          description: 'Name of the member who paid',
        },
        amount: {
          type: 'number',
          description: 'Amount paid by the member',
        },
      },
      required: ['gathering_id', 'member_name', 'amount'],
    },
  • MCP CallTool request handler for 'add_expense': validates arguments with isExpenseArgs type guard and constructs/executes Python CLI command 'add-expense' with provided parameters.
    case 'add_expense':
      if (!isExpenseArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid add_expense arguments');
      }
      command += ` add-expense "${args.gathering_id}" "${args.member_name}" ${args.amount}`;
      break;
  • CLI command handler for 'add-expense': calls GatheringService.add_expense and returns JSON or formatted success/error response.
    def handle_add_expense(service, args):
        """Handle the add-expense command."""
        try:
            gathering, member = service.add_expense(args.gathering_id, args.member_name, args.amount)
            result = {
                "success": True,
                "expense": {
                    "member": member.name,
                    "amount": args.amount,
                    "total_expenses": gathering.total_expenses
                }
            }
            if args.json:
                print(json.dumps(result))
            else:
                print(f"Added expense of ${args.amount:.2f} for {member.name}")
                print(f"Total expenses: ${gathering.total_expenses:.2f}")
            return True
        except ValueError as e:
            error = {"success": False, "error": str(e)}
            if args.json:
                print(json.dumps(error))
            else:
                print(f"Error: {e}")
            return False
  • Core DatabaseManager.add_expense implementation: validates input, handles unnamed member auto-renaming, inserts Expense record into DB, refreshes and returns updated Gathering and Member.
    def add_expense(self, gathering_id: str, member_name: str, amount: float) -> Tuple[Gathering, Member]:
        """
        Add an expense for a member.
        
        Args:
            gathering_id: The ID of the gathering
            member_name: The name of the member
            amount: The expense amount (positive number)
            
        Returns:
            Tuple of (updated Gathering, Member who paid)
            
        Raises:
            ValueError: If the gathering is closed, the member doesn't exist, or the amount is invalid
        """
        if amount <= 0:
            raise ValueError("Expense amount must be positive")
        
        session = self.Session()
        try:
            # Get the gathering
            gathering = session.query(Gathering).filter_by(id=gathering_id).first()
            if not gathering:
                raise ValueError(f"Gathering '{gathering_id}' not found")
            
            # Check if gathering is open
            if gathering.status == GatheringStatus.CLOSED:
                raise ValueError(f"Cannot add expense to closed gathering '{gathering_id}'")
            
            # Get the member
            member = session.query(Member).filter_by(gathering_id=gathering_id, name=member_name).first()
            if not member:
                # If member name doesn't exist, check if we need to rename an existing member
                # Get available unnamed members
                unnamed_members = session.query(Member).filter(
                    Member.gathering_id == gathering_id,
                    Member.name.like("member%")
                ).all()
                
                if not unnamed_members:
                    raise ValueError(f"Member '{member_name}' not found in gathering '{gathering_id}'")
                
                # Use the first available unnamed member and rename it
                member = unnamed_members[0]
                member.name = member_name
            
            # Add the expense
            expense = Expense(member_id=member.id, amount=amount)
            session.add(expense)
            
            session.commit()
            
            # Get fresh copies of the gathering and member
            updated_gathering = self.get_gathering(gathering_id)
            
            # Find the member in the updated gathering
            updated_member = None
            for m in updated_gathering.members:
                if m.name == member_name:
                    updated_member = m
                    break
                    
            if not updated_member:
                raise ValueError(f"Cannot find member '{member_name}' after adding expense")
                
            return updated_gathering, updated_member
            
        except Exception as e:
            session.rollback()
            raise e
        finally:
            session.close()
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Add an expense') but lacks details on permissions needed, whether it's idempotent, how it affects the system (e.g., updates balances), or error handling. This is a significant gap for a mutation tool.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero waste. It's appropriately sized and front-loaded, clearly stating the core action without unnecessary details.

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 the complexity of a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain return values, error cases, or how it integrates with sibling tools (e.g., impact on 'calculate_reimbursements'), leaving gaps for an AI agent.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all three parameters (gathering_id, member_name, amount) with descriptions. The description adds no additional meaning beyond what the schema provides, such as context or examples, meeting the baseline for high coverage.

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 verb ('Add') and resource ('expense for a member'), making the purpose understandable. It doesn't explicitly distinguish from sibling tools like 'record_payment' or 'calculate_reimbursements', which might handle similar financial transactions, so it misses full sibling differentiation.

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?

No guidance is provided on when to use this tool versus alternatives like 'record_payment' or in what context (e.g., during a gathering, for reimbursement calculations). The description implies usage for adding expenses but offers no exclusions or prerequisites.

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/abutbul/gatherings-mcp'

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