create_label
Create labels in Google Keep to categorize and organize your notes.
Instructions
Create a label.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/server/cli.py:267-273 (handler)The MCP tool handler for 'create_label'. It gets the Keep client, creates a label via keep.createLabel(name), syncs, and returns the serialized label as JSON.
@mcp.tool() def create_label(name: str) -> str: """Create a label.""" keep = get_client() label = keep.createLabel(name) keep.sync() return json.dumps(serialize_label(label)) - src/server/cli.py:267-267 (registration)The @mcp.tool() decorator registers create_label as an MCP tool on the FastMCP instance named 'mcp'.
@mcp.tool() - src/server/keep_api.py:58-59 (schema)The serialize_label helper, which converts a label object to a dict with 'id' and 'name' fields for JSON output.
def serialize_label(label): return {'id': label.id, 'name': label.name} - src/server/keep_api.py:10-56 (helper)The get_client() helper, which initializes and returns the Google Keep API client used by create_label.
def get_client(): """ Get or initialize the Google Keep client. This ensures we only authenticate once and reuse the client. Returns: gkeepapi.Keep: Authenticated Keep client """ global _keep_client if _keep_client is not None: return _keep_client # Load environment variables load_dotenv() # Get credentials from environment variables email = os.getenv('GOOGLE_EMAIL') master_token = os.getenv('GOOGLE_MASTER_TOKEN') if not email or not master_token: raise ValueError("Missing Google Keep credentials. Please set GOOGLE_EMAIL and GOOGLE_MASTER_TOKEN environment variables.") # Initialize the Keep API keep = gkeepapi.Keep() # Authenticate try: keep.authenticate(email, master_token) except requests.exceptions.JSONDecodeError as exc: raise RuntimeError( "Google Keep API returned a non-JSON response during authentication. " "This usually means the unofficial Keep API (notes/v1) is inaccessible " "from this environment (HTTP 403/4xx). " "Check that your GOOGLE_MASTER_TOKEN is valid and that the Keep API " "is reachable from this network." ) from exc except gkeepapi.exception.LoginException as exc: raise RuntimeError( f"Google Keep login failed: {exc}. " "Verify that GOOGLE_EMAIL and GOOGLE_MASTER_TOKEN are correct." ) from exc # Store the client for reuse _keep_client = keep return keep - src/server/cli.py:14-14 (registration)The FastMCP instance 'mcp' on which tools like create_label are registered.
mcp = FastMCP("keep")