Apple Doc MCP

repository·main·Indexed 20 days ago

https://github.com/mightydillah/apple-doc-mcp

A Model Context Protocol (MCP) server that provides AI coding assistants with direct access to Apple Developer Documentation. It enables agents to discover frameworks, search for symbols using exact names or wildcards, and retrieve detailed documentation for Apple-platform-specific code. The server includes tools such as discover_technologies, search_symbols, and get_documentation, and is compatible with clients like VS Code, Claude Code, and OpenAI Codex.

Tokens
4.6K
Snippets
23
Records
27
Agent score
71%

What's inside apple-doc-mcp

  1. Local Development Setup

    main

    To run the server from a local clone of the repository, build it using yarn and point your MCP configuration to the absolute path of the compiled dist/index.js file.

    yarn install
    yarn build

    Configuration Example:

    {
      "mcpServers": {
        "apple-docs": {
          "command": "node",
          "args": ["/absolute/path/to/apple-doc-mcp/dist/index.js"]
        }
      }
    }
  2. Search Tips for Apple Doc MCP

    main

    To get the best results when using search_symbols, follow these strategies:

    • Use Exact Names: If you know the API name, use it directly (e.g., "GridItem", "ButtonStyle", "View").
    • Start Broad: Use general terms like "tab", "animation", or "gesture" to explore.
    • Use Synonyms: Try related terms like "sheet" vs "modal" or "toolbar" vs "tabbar".
    • Wildcards: Use * and ? for flexible matching (e.g., "Grid*", "*Item", "Lazy*").
    • Multi-keyword Queries: Use multiple words (e.g., "tab view layout") to narrow down results.
    • Troubleshooting: If no results appear, try running discover_technologies with a different keyword or switching frameworks.
  3. Install Apple Doc MCP in VS Code

    main

    To add the Apple Doc MCP server to VS Code, use the built-in MCP extension interface:

    1. Open the Command Palette (Shift+Cmd+P).
    2. Run MCP: Add Server.
    3. When prompted for server type, choose npm.
    4. Enter the package name: apple-doc-mcp-server.
  4. Run the Apple Developer Documentation MCP server via stdio

    main

    The Apple Developer Documentation MCP server is designed to run using the stdio transport mechanism. This allows it to be integrated with MCP-compatible clients (like Claude Desktop or other IDE extensions) that communicate with servers via standard input and output. When started, the server initializes and begins listening for requests on stdin and sending responses via stdout. Log messages are directed to stderr to avoid interfering with the JSON-RPC communication protocol.

    # Example of running the server directly if installed as a CLI tool
    npx apple-doc-mcp-server
  5. Configure ESLint for Apple Doc MCP

    main

    The project uses ESLint with TypeScript type-checking and Prettier integration. The configuration targets files in src/**/*.ts and applies recommended rules from @eslint/js and typescript-eslint.

    Key configuration details:

    • Parser Options: Uses projectService: true and sets tsconfigRootDir to the current directory for type-aware linting.
    • Globals: Configured for a Node.js environment.
    • Ignored Paths: dist/**, node_modules/**, .cache/**, and *.d.ts files are excluded from linting.
    • Plugins: Includes eslint-plugin-n (Node.js plugin) and eslint-config-prettier to prevent conflicts with formatting.
    import js from '@eslint/js';
    import globals from 'globals';
    import n from 'eslint-plugin-n';
    import tseslint from 'typescript-eslint';
    import eslintConfigPrettier from 'eslint-config-prettier';
    
    export default tseslint.config(
    	{
    		ignores: ['dist/**', 'node_modules/**', '.cache/**', '*.d.ts'],
    	},
    	js.configs.recommended,
    	...tseslint.configs.recommendedTypeChecked,
    	{
    		files: ['src/**/*.ts'],
    		languageOptions: {
    			ecmaVersion: 'latest',
    			sourceType: 'module',
    			globals: globals.node,
    			parserOptions: {
    				projectService: true,
    				tsconfigRootDir: import.meta.dirname,
    			},
    		},
    		plugins: {
    			n,
    		},
    		rules: {
    			// ... rules
    		},
    	},
    	eslintConfigPrettier,
    );
  6. Available Tools in Apple Doc MCP

    main

    The server provides the following tools to interact with Apple Developer Documentation:

    • discover_technologies: Browse or filter available frameworks before selecting one.
    • choose_technology: Set the active framework. Note: This is required before you can search documentation.
    • current_technology: Displays the currently selected framework and provides quick next steps.
    • search_symbols: Performs a symbol-first search. It supports exact-name resolution, wildcard patterns (*, ?), and returns symbols and articles in separate sections.
    • get_documentation: Retrieves detailed documentation for a specific known symbol or documentation path.
    • get_version: Returns the current version of the MCP server.
  7. Initialize the MCP server with createServer()

    main

    Use createServer() to instantiate a new Model Context Protocol (MCP) server configured for Apple Developer Documentation. This function initializes the underlying MCP Server with the name apple-dev-docs-mcp, automatically sets the version from the package configuration, and enables tools capabilities. It also internally wires up the AppleDevDocsClient and ServerState, and registers all available documentation tools. The returned object is a standard MCP Server instance that can be connected to MCP clients like Claude Desktop or other compatible hosts.

    import { createServer } from './path/to/app.js';
    
    const server = createServer();
    // The server is now ready to be connected to an MCP transport (e.g., Stdio)
  8. Use AppleDevDocsClient to interact with Apple Developer Documentation

    main

    The AppleDevDocsClient is the primary entry point for retrieving Apple developer documentation, including framework data, specific symbols, and technology lists. It includes built-in file caching to optimize performance and reduce network requests.

    Key capabilities:

    • Retrieve Frameworks: Fetch full documentation for a specific framework.
    • Retrieve Symbols: Fetch detailed information for a specific documentation path/symbol.
    • Search Frameworks: Perform keyword or wildcard searches within a specific framework's documentation.
    • Technology Discovery: List available technologies supported by the API.
    import { AppleDevDocsClient } from './apple-client';
    
    const client = new AppleDevDocsClient();
    
    // Get framework data
    const framework = await client.getFramework('SwiftUI');
    
    // Get specific symbol data
    const symbol = await client.getSymbol('/swiftui/views/text');
    
    // Search within a framework
    const searchResults = await client.searchFramework('SwiftUI', 'Text', {
      maxResults: 5,
      platform: 'iOS'
    });