create_tag
Create a new tag with a specified name and color to organize and categorize your personal finances.
Instructions
Create a new tag. Color is a hex string like '#ff0000'.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| color | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/monarch_mcp/server.py:140-144 (handler)The handler function for the 'create_tag' tool. It is decorated with @mcp.tool() to register it as an MCP tool, accepts 'name' (str) and 'color' (str) parameters, obtains an authenticated MonarchMoney client, and delegates to the upstream library's create_transaction_tag method.
@mcp.tool() async def create_tag(name: str, color: str) -> dict[str, Any]: """Create a new tag. Color is a hex string like '#ff0000'.""" client = await _get_client() return await client.create_transaction_tag(name=name, color=color) - src/monarch_mcp/server.py:140-141 (registration)The @mcp.tool() decorator on line 140 registers 'create_tag' as a tool in the FastMCP server instance (line 31: mcp = FastMCP('monarch-mcp')).
@mcp.tool() async def create_tag(name: str, color: str) -> dict[str, Any]: - src/monarch_mcp/server.py:141-141 (schema)Input schema: the tool accepts two string parameters: 'name' (the tag name) and 'color' (a hex color string like '#ff0000'). Return type is dict[str, Any].
async def create_tag(name: str, color: str) -> dict[str, Any]: - src/monarch_mcp/server.py:37-69 (helper)Helper function that returns an authenticated MonarchMoney client instance, used by the create_tag handler to make the API call.
async def _get_client() -> MonarchMoney: """Return a logged-in MonarchMoney client, reusing the session pickle.""" global _client if _client is not None: return _client async with _login_lock: if _client is not None: return _client SESSION_DIR.mkdir(parents=True, exist_ok=True) client = MonarchMoney(session_file=str(SESSION_FILE)) if SESSION_FILE.exists(): try: client.load_session(str(SESSION_FILE)) _client = client return _client except Exception: pass # fall through to fresh login email, password, mfa_secret = auth.require_login_credentials() try: await client.login( email=email, password=password, use_saved_session=False, save_session=True, mfa_secret_key=mfa_secret, ) except RequireMFAException as exc: raise RuntimeError( "Monarch requires MFA but no TOTP secret is stored. " "Re-run `monarch-mcp-setup set` and provide the MFA secret." ) from exc _client = client return _client