Skip to main content
Glama

listProjects

Retrieve all projects associated with the authenticated user on DeepWriter MCP Server using a valid API key. Simplify project management and access content generation tools efficiently.

Instructions

List all projects for the authenticated user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
api_keyYesThe DeepWriter API key for authentication.

Implementation Reference

  • Core handler function that executes the listProjects tool: fetches projects via API using env API key, transforms to MCP content format.
    export const listProjectsTool = {
      name: "listProjects",
      description: "List all projects for the authenticated user",
      // TODO: Add input/output schema validation if needed
      async execute(args: ListProjectsInput): Promise<ListProjectsOutput> {
        console.error(`Executing listProjects tool...`);
    
        // Get API key from environment
        const apiKey = process.env.DEEPWRITER_API_KEY;
        if (!apiKey) {
          throw new Error("DEEPWRITER_API_KEY environment variable is required");
        }
    
        try {
          // Call the actual API client function
          const apiResponse = await apiClient.listProjects(apiKey);
          console.error(`API call successful. Received ${apiResponse.projects.length} projects.`);
    
          // Transform the API response into MCP format
          const mcpResponse: ListProjectsOutput = {
            content: apiResponse.projects.map(project => ({
              type: 'text',
              text: `Project ID: ${project.id}, Title: ${project.title}, Created: ${project.created_at}`
            }))
          };
    
          if (mcpResponse.content.length === 0) {
            mcpResponse.content.push({ type: 'text', text: 'No projects found.' });
          }
    
          return mcpResponse; // Return the MCP-compliant structure
        } catch (error) {
          console.error(`Error executing listProjects tool: ${error}`);
          // Format error for MCP response
          // Ensure error is an instance of Error before accessing message
          const errorMessage = error instanceof Error ? error.message : String(error);
          throw new Error(`Failed to list projects: ${errorMessage}`);
        }
      }
    };
  • src/index.ts:189-209 (registration)
    Registers the listProjectsTool with the MCP server using server.tool(), providing empty input schema and wrapper around execute.
    server.tool(
      listProjectsTool.name,
      listProjectsTool.description,
      {
        // No parameters - API key from environment
      },
      async (params: ListProjectsParams) => {
        console.error(`SDK invoking ${listProjectsTool.name}...`);
        const result = await listProjectsTool.execute({});
        return {
          content: result.content,
          annotations: {
            title: "List Projects",
            readOnlyHint: true, // This tool only reads data
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: false // Only accesses DeepWriter API
          }
        };
      }
    );
  • Type definitions for tool input (empty), intermediate Project, and MCP output structure.
    interface ListProjectsInput {
      // No parameters needed - API key from environment
    }
    
    interface Project {
      id: string;
      title: string;
      created_at: string;
      // Add other relevant fields if needed
    }
    
    // Define the MCP-compliant output structure
    interface ListProjectsOutput {
      content: { type: 'text'; text: string }[];
    }
  • Zod input schema for listProjects tool registration (empty object).
    const listProjectsInputSchema = z.object({}); // No parameters needed
  • API client helper: makes GET request to DeepWriter /api/listProjects endpoint and returns typed response.
    interface ListProjectsResponse {
      projects: ProjectListItem[];
      // Add other potential fields like pagination info if applicable
    }
    
    export async function listProjects(apiKey: string): Promise<ListProjectsResponse> {
      console.error("Calling actual listProjects API");
      if (!apiKey) {
        throw new Error("API key is required for listProjects");
      }
      // Actual implementation:
      return makeApiRequest<ListProjectsResponse>('/api/listProjects', apiKey, 'GET');
    }
Install Server

Other Tools

Related 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/deepwriter-ai/Deepwriter-MCP'

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