|
| 1 | +# Contributing to osint-mcp-server |
| 2 | + |
| 3 | +Thanks for your interest in contributing! This guide will help you get started. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +```bash |
| 8 | +# Clone the repo |
| 9 | +git clone https://github.com/badchars/osint-mcp-server.git |
| 10 | +cd osint-mcp-server |
| 11 | + |
| 12 | +# Install dependencies (Bun recommended) |
| 13 | +bun install |
| 14 | + |
| 15 | +# Build |
| 16 | +bun run build |
| 17 | + |
| 18 | +# Run in dev mode (watch) |
| 19 | +bun run dev |
| 20 | + |
| 21 | +# Test a tool |
| 22 | +node dist/index.js --tool dns_lookup '{"domain":"example.com","type":"A"}' |
| 23 | + |
| 24 | +# List all tools |
| 25 | +node dist/index.js --list |
| 26 | +``` |
| 27 | + |
| 28 | +## Project Structure |
| 29 | + |
| 30 | +``` |
| 31 | +src/ |
| 32 | +├── index.ts # Entry point (MCP server + CLI) |
| 33 | +├── types/index.ts # ToolDef, ToolContext, ToolResult types |
| 34 | +├── protocol/ |
| 35 | +│ ├── mcp-server.ts # MCP stdio transport |
| 36 | +│ └── tools.ts # allTools array (all 37 tools) |
| 37 | +└── tools/ |
| 38 | + ├── dns/ # DNS tools (6) |
| 39 | + ├── whois/ # WHOIS / RDAP tools (2) |
| 40 | + ├── crtsh/ # Certificate Transparency (1) |
| 41 | + ├── geoip/ # GeoIP tools (2) |
| 42 | + ├── bgp/ # BGP / ASN tools (3) |
| 43 | + ├── wayback/ # Wayback Machine tools (2) |
| 44 | + ├── hackertarget/ # HackerTarget tools (3) |
| 45 | + ├── m365/ # Microsoft 365 tools (2) |
| 46 | + ├── meta/ # Meta tools (2) |
| 47 | + ├── shodan/ # Shodan tools (4) — requires API key |
| 48 | + ├── virustotal/ # VirusTotal tools (4) — requires API key |
| 49 | + ├── securitytrails/ # SecurityTrails tools (3) — requires API key |
| 50 | + └── censys/ # Censys tools (3) — requires API key |
| 51 | +``` |
| 52 | + |
| 53 | +## Adding a New Tool |
| 54 | + |
| 55 | +1. Create the tool file in the appropriate `src/tools/<provider>/` directory |
| 56 | +2. Follow the `ToolDef` interface: |
| 57 | + |
| 58 | +```typescript |
| 59 | +import { z } from "zod"; |
| 60 | +import type { ToolDef, ToolContext, ToolResult } from "../../types/index.js"; |
| 61 | + |
| 62 | +const schema = z.object({ |
| 63 | + domain: z.string().describe("Target domain"), |
| 64 | +}); |
| 65 | + |
| 66 | +export const myNewTool: ToolDef = { |
| 67 | + name: "provider_tool_name", |
| 68 | + description: "What this tool does in one sentence", |
| 69 | + inputSchema: schema, |
| 70 | + execute: async (args, ctx): Promise<ToolResult> => { |
| 71 | + const { domain } = schema.parse(args); |
| 72 | + |
| 73 | + // Your implementation here |
| 74 | + const result = { domain, data: "..." }; |
| 75 | + |
| 76 | + return { |
| 77 | + content: [{ type: "text", text: JSON.stringify(result, null, 2) }], |
| 78 | + }; |
| 79 | + }, |
| 80 | +}; |
| 81 | +``` |
| 82 | + |
| 83 | +3. Add the tool to `src/protocol/tools.ts`: |
| 84 | + |
| 85 | +```typescript |
| 86 | +import { myNewTool } from "../tools/provider/my-new-tool.js"; |
| 87 | + |
| 88 | +export const allTools: ToolDef[] = [ |
| 89 | + // ... existing tools |
| 90 | + myNewTool, |
| 91 | +]; |
| 92 | +``` |
| 93 | + |
| 94 | +4. Add the tool to `TOOL_CATEGORIES` in `src/index.ts` |
| 95 | +5. Build and test: |
| 96 | + |
| 97 | +```bash |
| 98 | +bun run build |
| 99 | +node dist/index.js --tool provider_tool_name '{"domain":"example.com"}' |
| 100 | +``` |
| 101 | + |
| 102 | +## Adding a New Data Source |
| 103 | + |
| 104 | +1. Create a new directory under `src/tools/<provider>/` |
| 105 | +2. Implement one or more tools following the pattern above |
| 106 | +3. If the source requires an API key: |
| 107 | + - Add the key to `ToolContext.config` in `src/types/index.ts` |
| 108 | + - Read it from `process.env` in `src/index.ts` → `buildToolContext()` |
| 109 | + - Return a helpful error message when the key is missing |
| 110 | +4. Update README with the new source |
| 111 | + |
| 112 | +## Guidelines |
| 113 | + |
| 114 | +- **TypeScript strict mode** — no `any` types |
| 115 | +- **Zod schemas** — every tool input must be validated |
| 116 | +- **Native fetch** — no axios or other HTTP libraries |
| 117 | +- **Minimal dependencies** — currently only 2 runtime deps (MCP SDK + Zod) |
| 118 | +- **Graceful API key handling** — tools that need keys should return a clear message, not crash |
| 119 | +- **Conventional Commits** — `feat:`, `fix:`, `docs:`, `refactor:` |
| 120 | + |
| 121 | +## Submitting a PR |
| 122 | + |
| 123 | +1. Fork the repo and create a branch from `main` |
| 124 | +2. Make your changes |
| 125 | +3. Run `bun run build` and test your changes |
| 126 | +4. Push and open a PR — the template will guide you |
| 127 | + |
| 128 | +## Reporting Issues |
| 129 | + |
| 130 | +Use the [issue templates](https://github.com/badchars/osint-mcp-server/issues/new/choose): |
| 131 | +- **Bug Report** — something is broken |
| 132 | +- **Feature Request** — suggest an improvement |
| 133 | +- **New Data Source** — request a new OSINT provider integration |
0 commit comments