Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 86 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,94 @@ Get started fast with mcp-framework ⚡⚡⚡
## Features

- 🛠️ Automatic directory-based discovery and loading for tools, prompts, and resources
- 🏗️ Powerful abstractions
- 🏗️ Powerful abstractions with full type safety
- 🚀 Simple server setup and configuration
- 📦 CLI for rapid development and project scaffolding

## Installation
## Quick Start

### Using the CLI (Recommended)

```bash
# Install the framework globally
npm install -g mcp-framework

# Create a new MCP server project
mcp create my-mcp-server

# Navigate to your project
cd my-mcp-server

# Your server is ready to use!
```

### Manual Installation

```bash
npm install mcp-framework
```

## Quick Start
## CLI Usage

### 1. Create your MCP server:
The framework provides a powerful CLI for managing your MCP server projects:

```typescript
import { MCPServer } from "mcp-framework";
### Project Creation

```bash
# Create a new project
mcp create <your project name here>
```

const server = new MCPServer();
### Adding a Tool

server.start().catch((error) => {
console.error("Server failed to start:", error);
process.exit(1);
});
```bash
# Add a new tool
mcp add tool price-fetcher
```

### 2. Create a Tool:
### Adding a Prompt

```bash
# Add a new prompt
mcp add prompt price-analysis
```

### Adding a Resource

```bash
# Add a new prompt
mcp add resource market-data
```

## Development Workflow

1. Create your project:

```bash
mcp create my-mcp-server
cd my-mcp-server
```

2. Add tools as needed:

```bash
mcp add tool data-fetcher
mcp add tool data-processor
mcp add tool report-generator
```

3. Build and run:
```bash
npm run build
# or
npm run watch # for development
```

## Components Overview

### 1. Tools (Main Component)

Tools are the primary way to extend an LLM's capabilities. Each tool should perform a specific function:

```typescript
import { MCPTool } from "mcp-framework";
Expand Down Expand Up @@ -60,7 +123,9 @@ class ExampleTool extends MCPTool<ExampleInput> {
export default ExampleTool;
```

### 3. Create a Prompt:
### 2. Prompts (Optional)

Prompts help structure conversations with Claude:

```typescript
import { MCPPrompt } from "mcp-framework";
Expand Down Expand Up @@ -104,7 +169,9 @@ class GreetingPrompt extends MCPPrompt<GreetingInput> {
export default GreetingPrompt;
```

### 4. Create a Resource:
### 3. Resources (Optional)

Resources provide data access capabilities:

```typescript
import { MCPResource, ResourceContent } from "mcp-framework";
Expand Down Expand Up @@ -139,11 +206,11 @@ export default ConfigResource;
```
your-project/
├── src/
│ ├── tools/ # Tool implementations
│ ├── tools/ # Tool implementations (Required)
│ │ └── ExampleTool.ts
│ ├── prompts/ # Prompt implementations
│ ├── prompts/ # Prompt implementations (Optional)
│ │ └── GreetingPrompt.ts
│ ├── resources/ # Resource implementations
│ ├── resources/ # Resource implementations (Optional)
│ │ └── ConfigResource.ts
│ └── index.ts
├── package.json
Expand All @@ -155,8 +222,8 @@ your-project/
The framework automatically discovers and loads:

- Tools from the `src/tools` directory
- Prompts from the `src/prompts` directory
- Resources from the `src/resources` directory
- Prompts from the `src/prompts` directory (if present)
- Resources from the `src/resources` directory (if present)

Each feature should be in its own file and export a default class that extends the appropriate base class:

Expand Down
37 changes: 28 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mcp-framework",
"version": "0.1.8",
"version": "0.1.9",
"description": "Framework for building Model Context Protocol (MCP) servers in Typescript",
"type": "module",
"author": "Alex Andru <alex@andru.codes>",
Expand All @@ -16,7 +16,8 @@
"dist"
],
"bin": {
"mcp-build": "./dist/cli/build.js"
"mcp": "./dist/cli/index.js",
"mcp-build": "./dist/cli/framework/build.js"
},
"scripts": {
"build": "tsc",
Expand All @@ -36,6 +37,9 @@
"@modelcontextprotocol/sdk": "^0.6.0"
},
"dependencies": {
"@types/prompts": "^2.4.9",
"commander": "^12.1.0",
"prompts": "^2.4.2",
"zod": "^3.23.8"
},
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions src/cli/build.ts → src/cli/framework/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { spawnSync } from "child_process";
import { readFileSync, writeFileSync } from "fs";
import { join } from "path";

export function buildFramework() {
runTsc();
addShebang();
console.log("MCP Build complete");
}

function runTsc() {
const tscPath = join(process.cwd(), "node_modules", ".bin", "tsc");
const tsc = spawnSync(tscPath, [], {
Expand Down Expand Up @@ -30,9 +36,3 @@ function addShebang() {
process.exit(1);
}
}

runTsc();

addShebang();

console.log("MCP Build complete");
49 changes: 49 additions & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env node
import { Command } from "commander";
import { createProject } from "./project/create.js";
import { addTool } from "./project/add-tool.js";
import { addPrompt } from "./project/add-prompt.js";
import { addResource } from "./project/add-resource.js";
import { buildFramework } from "./framework/build.js";

const program = new Command();

program
.name("mcp")
.description("CLI for managing MCP server projects")
.version("0.1.8");

program
.command("build-framework", { hidden: true })
.description("Build the MCP framework")
.action(buildFramework);

program
.command("create")
.description("Create a new MCP server project")
.argument("[name]", "project name")
.action(createProject);

program
.command("add")
.description("Add a new component to your MCP server")
.addCommand(
new Command("tool")
.description("Add a new tool")
.argument("[name]", "tool name")
.action(addTool)
)
.addCommand(
new Command("prompt")
.description("Add a new prompt")
.argument("[name]", "prompt name")
.action(addPrompt)
)
.addCommand(
new Command("resource")
.description("Add a new resource")
.argument("[name]", "resource name")
.action(addResource)
);

program.parse();
Loading