Skip to main content
Glama

Smart Code Search MCP Server

python_sample.py2.34 kB
"""Sample Python file for testing parser feature parity""" from typing import List, Dict, Optional import json import asyncio from dataclasses import dataclass # TODO: Add more comprehensive examples # FIXME: Handle edge cases in parsing @dataclass class User: """Represents a user in the system""" name: str email: str age: Optional[int] = None def __str__(self) -> str: return f"User({self.name})" class UserService: """Service for managing users""" def __init__(self, database_url: str): self.database_url = database_url self.users: Dict[str, User] = {} def add_user(self, user: User) -> bool: """Add a new user to the service Args: user: The user to add Returns: True if user was added, False if already exists Raises: ValueError: If user data is invalid """ if user.email in self.users: return False if not self._validate_email(user.email): raise ValueError(f"Invalid email: {user.email}") self.users[user.email] = user return True async def fetch_users(self) -> List[User]: """Fetch all users asynchronously""" await asyncio.sleep(0.1) # Simulate network delay return list(self.users.values()) def _validate_email(self, email: str) -> bool: """Internal method to validate email format""" return "@" in email and "." in email def process_user_data(data: Dict[str, any]) -> Optional[User]: """Process raw user data into User object This function handles various data formats and validates input. """ try: return User( name=data["name"], email=data["email"], age=data.get("age") ) except KeyError as e: print(f"Missing required field: {e}") return None except Exception as e: # NOTE: Consider logging this error print(f"Error processing user data: {e}") return None # Global instance service = UserService("postgresql://localhost/users") if __name__ == "__main__": # Example usage user = User("John Doe", "john@example.com", 30) service.add_user(user) print(f"Added user: {user}")

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/stevenjjobson/scs-mcp'

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