Skip to content

Commit 4e99078

Browse files
committed
add AGENTS.md
1 parent 4fdff86 commit 4e99078

2 files changed

Lines changed: 69 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Project Overview
2+
3+
- **Purpose**: This project is an MCP (Model Context Protocol) server that provides API and GraphQL documentation and search capabilities. It enables AI agents and tools to access and query API documentation from various sources (files or URLs) in a structured format.
4+
- **Key Features**:
5+
- Automatic GraphQL schema introspection and documentation extraction from local files (.graphql, .gql, .json) or remote URLs
6+
- Two primary tools: `api_docs` (list all API methods) and `api_search` (get detailed documentation for specific methods)
7+
- Caching with TTL to minimize redundant schema fetches
8+
- Support for queries, mutations, and subscriptions in GraphQL schemas
9+
- Configurable through environment variables for multiple API sources
10+
- **Technology Stack**:
11+
- **Languages**: TypeScript (ES2022)
12+
- **Frameworks**: Model Context Protocol SDK (@modelcontextprotocol/sdk)
13+
- **Key Libraries**: GraphQL (16.11.0), graphql-tools for schema loading and introspection, Zod for schema validation
14+
- **Infra**: Node.js (24.0.0+), pnpm package manager
15+
- **Build Tools**: TypeScript compiler with tsc-alias for path resolution
16+
17+
## Dev Environment Setup
18+
19+
Assume your current shell is `zsh` and your working directory for commands is the project root: `api-docs-mcp`.
20+
21+
- `pnpm install`: Install all dependencies from pnpm-lock.yaml (use `--frozen-lockfile` for CI/CD)
22+
- `pnpm run build`: Compile TypeScript to JavaScript in the `build/` directory with type declarations and source maps
23+
- `pnpm run dev`: Run TypeScript compiler in watch mode for development (outputs to `build/` on file changes)
24+
- `pnpm run start`: Execute the compiled MCP server from `build/index.js` (must build first)
25+
- `node build/index.js`: Alternative way to start the server after building
26+
27+
**Environment Configuration**:
28+
29+
- The server requires `API_SOURCES` environment variable containing a JSON array of schema sources
30+
- Example: `API_SOURCES='[{"name":"GitHub","type":"gql","url":"https://api.github.com/graphql","method":"POST","headers":{"Authorization":"Bearer token"}}]'`
31+
- Sources can be file-based (with `path` property) or URL-based (with `url` and `method` properties)
32+
33+
## Project Layout
34+
35+
- **Configuration Files**:
36+
- `package.json`: Project metadata, dependencies, scripts, and npm package configuration with bin entry point
37+
- `tsconfig.json`: TypeScript compiler configuration with ES2022 target, ESNext modules, path aliases (src/\*), and tsc-alias settings
38+
- `.eslintrc.json`: ESLint rules including TypeScript, Prettier integration, and code style enforcement (2-space indent, single quotes, semicolons required)
39+
- `pnpm-lock.yaml`: Locked dependency versions for reproducible builds
40+
- `LICENSE`: Apache-2.0 license file
41+
42+
- **Architectural Elements**:
43+
- **Entry Point**:
44+
- `src/index.ts`: Main executable entry point with shebang, initializes server with StdioServerTransport, registers tools, and sets up cache refresh interval
45+
- `src/server.ts`: MCP server instance creation and tool registration logic (dynamically loads all tool files from `src/tools/`)
46+
- **Tools** (MCP server capabilities):
47+
- `src/tools/api_docs.ts`: Tool for listing all available API methods from configured sources with structured output
48+
- `src/tools/api_search.ts`: Tool for retrieving detailed documentation of specific API methods by name
49+
- **GraphQL Processing**:
50+
- `src/gql/gql.ts`: Core GraphQL schema processing logic that extracts queries, mutations, subscriptions, and builds detailed field structures with type information, enum values, and descriptions
51+
- **Utilities**:
52+
- `src/utils/cache.ts`: Cache management with CacheEntry interface, TTL-based expiration (12h), and refresh logic for both file and URL sources
53+
- `src/utils/config.ts`: Environment variable parsing for `API_SOURCES` configuration
54+
- `src/utils/fetch.ts`: HTTP fetch utilities for remote GraphQL introspection queries
55+
- `src/utils/file.ts`: File system operations for reading local schema files (.json, .graphql, .gql)
56+
- `src/utils/source.ts`: Type definitions and type guards for FileSource, UrlSource, and SchemaSource with SourceType enum (currently only GQL)
57+
- **CI/CD**:
58+
- `.github/workflows/publish.yml`: GitHub Actions workflow for automated npm publishing on main branch (version bump, build, publish with `[skip ci]` commit tagging)
59+
60+
- **Code Style Guidelines**:
61+
- Use 2-space indentation consistently
62+
- Single quotes for strings
63+
- Semicolons required at statement ends
64+
- Avoid `any` types (enforced by ESLint)
65+
- Minimize console usage (console.log triggers warnings)
66+
- Use path aliases (e.g., `src/*`) instead of relative imports
67+
- Follow async/await patterns for asynchronous operations
68+
- Type all function parameters and return values explicitly where possible

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"README.md"
1515
],
1616
"engines": {
17-
"node": ">=18.0.0"
17+
"node": ">=24.0.0"
1818
},
1919
"publishConfig": {
2020
"access": "public"

0 commit comments

Comments
 (0)