Skip to main content
Glama
DollhouseMCP

DollhouseMCP

Official

init_portfolio

Create a GitHub repository to store and organize DollhouseMCP elements with proper directory structure and documentation.

Instructions

Initialize a new GitHub portfolio repository for storing your DollhouseMCP elements. Creates the repository structure with proper directories and README.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repository_nameNoName for the portfolio repository. Defaults to 'dollhouse-portfolio' if not specified.
privateNoWhether to create a private repository. Defaults to false (public).
descriptionNoRepository description. Defaults to 'My DollhouseMCP element portfolio'.

Implementation Reference

  • MCP tool registration for 'init_portfolio' including full input schema, description, and handler function that delegates to server.initPortfolio method.
      tool: {
        name: "init_portfolio",
        description: "Initialize a new GitHub portfolio repository for storing your DollhouseMCP elements. Creates the repository structure with proper directories and README.",
        inputSchema: {
          type: "object",
          properties: {
            repository_name: {
              type: "string",
              description: "Name for the portfolio repository. Defaults to 'dollhouse-portfolio' if not specified.",
            },
            private: {
              type: "boolean",
              description: "Whether to create a private repository. Defaults to false (public).",
            },
            description: {
              type: "string",
              description: "Repository description. Defaults to 'My DollhouseMCP element portfolio'.",
            },
          },
        },
      },
      handler: (args: InitPortfolioArgs) => server.initPortfolio({
        repositoryName: args?.repository_name,
        private: args?.private,
        description: args?.description
      })
    },
  • TypeScript interface defining the input arguments for the init_portfolio tool.
    interface InitPortfolioArgs {
      repository_name?: string;
      private?: boolean;
      description?: string;
    }
  • Core implementation logic for creating the GitHub portfolio repository. Handles consent validation, existence checks, API calls to GitHub, error handling with specific codes, and initializes repository structure with README.md and element directories. This is the primary execution logic called by init_portfolio.
    async createPortfolio(username: string, consent: boolean | undefined): Promise<string> {
      // MEDIUM FIX: Normalize username to prevent Unicode attacks (DMCP-SEC-004)
      const normalizedUsername = UnicodeValidator.normalize(username).normalizedContent;
      
      // CRITICAL: Validate consent is explicitly provided
      if (consent === undefined) {
        throw new Error('Consent is required for portfolio creation');
      }
    
      if (!consent) {
        logger.info(`User declined portfolio creation for ${username}`);
        throw new Error('User declined portfolio creation');
      }
    
      // Log consent for audit trail
      logger.info(`User consented to portfolio creation for ${normalizedUsername}`);
      
      // LOW FIX: Add security audit logging (DMCP-SEC-006)
      SecurityMonitor.logSecurityEvent({
        type: 'PORTFOLIO_INITIALIZATION',
        severity: 'LOW',
        source: 'PortfolioRepoManager.createPortfolio',
        details: `User ${normalizedUsername} consented to portfolio creation`,
        metadata: { username: normalizedUsername }
      });
    
      // Check if portfolio already exists
      const existingRepo = await this.githubRequest(
        `/repos/${normalizedUsername}/${this.repositoryName}`
      );
      
      if (existingRepo && existingRepo.html_url) {
        logger.info(`Portfolio already exists for ${normalizedUsername}`);
        return existingRepo.html_url;
      }
    
      // Create the portfolio repository
      try {
        const repo = await this.githubRequest(
          '/user/repos',
          'POST',
          {
            name: this.repositoryName,
            description: PortfolioRepoManager.DEFAULT_DESCRIPTION,
            private: false,
            auto_init: true
          }
        );
    
        // Initialize portfolio structure
        await this.generatePortfolioStructure(normalizedUsername);
    
        return repo.html_url;
      } catch (error: any) {
        // Handle race condition: if repository was created between our check and creation attempt
        if (error.message && error.message.includes('name already exists')) {
          logger.info(`Portfolio repository already exists for ${normalizedUsername} (race condition handled)`);
          
          // Re-check for the existing repository and return its URL
          try {
            const existingRepo = await this.githubRequest(
              `/repos/${normalizedUsername}/${this.repositoryName}`
            );
            if (existingRepo && existingRepo.html_url) {
              return existingRepo.html_url;
            }
          } catch (recheckError) {
            ErrorHandler.logError('PortfolioRepoManager.recheckExistingRepo', recheckError, { username: normalizedUsername });
          }
          
          // If we can't get the existing repo, throw a more specific error
          throw new Error(`Portfolio repository already exists for ${normalizedUsername}. Please check your GitHub account.`);
        }
        
        ErrorHandler.logError('PortfolioRepoManager.createPortfolioRepo', error, { username: normalizedUsername });
        throw ErrorHandler.wrapError(error, `Failed to create portfolio repository for ${normalizedUsername}. ${error.message || 'Unknown error occurred.'}`, ErrorCategory.NETWORK_ERROR);
      }
    }
  • IToolHandler interface defining the server.initPortfolio method signature used by the tool handler.
    initPortfolio(options: {repositoryName?: string; private?: boolean; description?: string}): Promise<any>;
  • Helper method for making authenticated GitHub API requests, used by createPortfolio for repo creation and structure initialization.
    public async githubRequest(
      path: string,
      method: string = 'GET',
      body?: any
    ): Promise<any> {
      const token = await this.getTokenAndValidate();
      const url = `${PortfolioRepoManager.GITHUB_API_BASE}${path}`;
      
      const options: RequestInit = {
        method,
        headers: {
          'Authorization': `Bearer ${token}`,
          'Accept': 'application/vnd.github.v3+json',
          'Content-Type': 'application/json',
          'User-Agent': 'DollhouseMCP/1.0'
        }
      };
    
      if (body) {
        options.body = JSON.stringify(body);
      }
    
      const response = await fetch(url, options);
      
      // Check if response exists before accessing properties
      if (!response) {
        const error: any = new Error('No response received from GitHub API');
        error.status = 0;
        error.code = 'PORTFOLIO_SYNC_005';
        throw error;
      }
      
      if (response.status === 404) {
        return null; // Not found is often expected
      }
    
      // Check if response is ok BEFORE trying to parse JSON
      if (!response.ok) {
        // Try to parse error details if response is JSON
        let data: any = {};
        // HTTP headers are case-insensitive, check both cases for robustness
        const contentType = response.headers.get('content-type') || response.headers.get('Content-Type');
        if (contentType && contentType.toLowerCase().includes('application/json')) {
          try {
            data = await response.json();
          } catch (jsonError) {
            // JSON parsing failed for error response - continue with empty data
            // This can happen if GitHub returns malformed JSON or content-type mismatch
            if (process.env.DEBUG) {
              console.debug('Failed to parse JSON error response:', jsonError);
            }
          }
        }
    
        // Create error with status code attached for better classification
        let errorMessage = data.message || `GitHub API error: ${response.status}`;
        let errorCode = 'PORTFOLIO_SYNC_005'; // Default
    
        switch (response.status) {
          case 401:
            errorMessage = 'GitHub authentication failed. Please check your token.';
            errorCode = 'PORTFOLIO_SYNC_001';
            break;
          case 403:
            if (data.message?.includes('rate limit')) {
              errorMessage = `GitHub API rate limit exceeded: ${data.message}`;
              errorCode = 'PORTFOLIO_SYNC_006';
            } else {
              errorMessage = `GitHub API access forbidden: ${data.message || 'insufficient permissions'}`;
              errorCode = 'PORTFOLIO_SYNC_001'; // Treat as auth issue
            }
            break;
          case 422:
            // Validation failed - often means repository already exists
            errorMessage = `Repository validation failed: ${data.message || 'name already exists on this account'}`;
            errorCode = 'PORTFOLIO_SYNC_003';
            break;
          case 500:
            errorMessage = 'GitHub API server error. Please try again later.';
            errorCode = 'PORTFOLIO_SYNC_005';
            break;
          default:
            errorMessage = `GitHub API error (${response.status}): ${data.message || 'Unknown error'}`;
        }
    
        const error: any = new Error(errorMessage);
        error.status = response.status;
        error.code = errorCode;
        throw error;
      }
    
      // Parse JSON only after we know response is ok
      const data = await response.json();
    
      return data;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It discloses the creation behavior but lacks critical details: whether this requires GitHub authentication (implied but not stated), what happens if the repository already exists, rate limits, or error handling. For a mutation tool with zero annotation coverage, this is a significant gap in behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core action and efficiently uses two sentences without redundancy. However, it could be more concise by merging the sentences (e.g., 'Initialize a new GitHub portfolio repository for DollhouseMCP elements, creating the structure with directories and README.') to reduce wordiness while maintaining clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a mutation tool. It covers the purpose but misses authentication requirements, error scenarios, and output details. With 3 parameters fully documented in the schema, it's minimally adequate but lacks behavioral and contextual depth needed for robust agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters with defaults. The description adds no parameter-specific information beyond implying repository creation, which is covered by the tool's purpose. Baseline 3 is appropriate as the schema handles parameter documentation adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Initialize a new GitHub portfolio repository') and resource ('for storing your DollhouseMCP elements'), distinguishing it from siblings like 'portfolio_status' or 'portfolio_config' that manage existing portfolios rather than creating new ones. It specifies the outcome ('Creates the repository structure with proper directories and README'), making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context ('for storing your DollhouseMCP elements') but does not explicitly state when to use this tool versus alternatives like 'portfolio_config' for configuration or 'sync_portfolio' for updates. No prerequisites (e.g., GitHub authentication) or exclusions are mentioned, leaving gaps in guidance for the agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/DollhouseMCP/mcp-server'

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