|
|
"""Test script to verify MCP tools work correctly.""" |
|
|
|
|
|
import sys |
|
|
sys.path.insert(0, '.') |
|
|
|
|
|
from app.database import init_db, SessionLocal |
|
|
from app.models import User, generate_user_id |
|
|
from app.tools.projects import create_project, list_projects, join_project |
|
|
from app.tools.tasks import create_task, list_tasks, list_activity |
|
|
|
|
|
|
|
|
def create_test_user(first_name: str, last_name: str) -> str: |
|
|
"""Create a test user and return their ID.""" |
|
|
db = SessionLocal() |
|
|
try: |
|
|
user_id = generate_user_id(first_name) |
|
|
user = User(id=user_id, first_name=first_name, last_name=last_name) |
|
|
db.add(user) |
|
|
db.commit() |
|
|
return user.id |
|
|
finally: |
|
|
db.close() |
|
|
|
|
|
|
|
|
def main(): |
|
|
|
|
|
print("Initializing database...") |
|
|
init_db() |
|
|
|
|
|
|
|
|
print("\n1. Creating test users...") |
|
|
user1_id = create_test_user("Alice", "Developer") |
|
|
user2_id = create_test_user("Bob", "Engineer") |
|
|
print(f" Created User 1: {user1_id}") |
|
|
print(f" Created User 2: {user2_id}") |
|
|
|
|
|
|
|
|
print("\n2. Testing create_project...") |
|
|
project = create_project( |
|
|
name="AI Memory System", |
|
|
description="Building a shared AI memory for dev teams", |
|
|
user_id=user1_id |
|
|
) |
|
|
print(f" Created project: {project}") |
|
|
project_id = project["id"] |
|
|
|
|
|
|
|
|
print("\n3. Testing list_projects...") |
|
|
projects = list_projects(user_id=user1_id) |
|
|
print(f" User 1's projects: {projects}") |
|
|
|
|
|
|
|
|
print("\n4. Testing join_project...") |
|
|
join_result = join_project(project_id=project_id, user_id=user2_id) |
|
|
print(f" Join result: {join_result}") |
|
|
|
|
|
|
|
|
projects2 = list_projects(user_id=user2_id) |
|
|
print(f" User 2's projects: {projects2}") |
|
|
|
|
|
|
|
|
print("\n5. Testing create_task...") |
|
|
task1 = create_task( |
|
|
project_id=project_id, |
|
|
title="Set up database schema", |
|
|
description="Create SQLAlchemy models for all entities", |
|
|
assigned_to=user1_id |
|
|
) |
|
|
print(f" Created task 1: {task1}") |
|
|
|
|
|
task2 = create_task( |
|
|
project_id=project_id, |
|
|
title="Implement MCP server", |
|
|
description="Set up MCP server with tool definitions" |
|
|
) |
|
|
print(f" Created task 2: {task2}") |
|
|
|
|
|
|
|
|
print("\n6. Testing list_tasks...") |
|
|
tasks = list_tasks(project_id=project_id) |
|
|
print(f" All tasks: {tasks}") |
|
|
|
|
|
|
|
|
print("\n7. Testing list_tasks with status filter...") |
|
|
todo_tasks = list_tasks(project_id=project_id, status="todo") |
|
|
print(f" Todo tasks: {todo_tasks}") |
|
|
|
|
|
|
|
|
print("\n8. Testing list_activity...") |
|
|
activity = list_activity(project_id=project_id) |
|
|
print(f" Activity (empty expected): {activity}") |
|
|
|
|
|
print("\n✅ All Foundation Layer tests passed!") |
|
|
print("\nReady for Dev B to implement:") |
|
|
print(" - complete_task (with LLM documentation generation)") |
|
|
print(" - memory_search (with vector search)") |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |
|
|
|