Skip to content
Open
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
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
.github/ export-ignore
.gitignore export-ignore
CLAUDE.md export-ignore
ncs.* export-ignore
phpstan*.neon export-ignore
tests/ export-ignore

*.php* diff=php
*.sh text eol=lf
mcp-inspector text eol=lf
31 changes: 31 additions & 0 deletions .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Coding Style

on: [push, pull_request]

jobs:
nette_cc:
name: Nette Code Checker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none

- run: composer create-project nette/code-checker temp/code-checker ^3 --no-progress
- run: php temp/code-checker/code-checker --strict-types --no-progress


nette_cs:
name: Nette Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none

- run: composer create-project nette/coding-standard temp/coding-standard ^3 --no-progress
- run: php temp/coding-standard/ecs check
21 changes: 21 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Static Analysis (only informative)

on:
push:
branches:
- master

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none

- run: composer install --no-progress --prefer-dist
- run: composer phpstan
continue-on-error: true # is only informative
60 changes: 60 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Tests

on: [push, pull_request]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.2', '8.3', '8.4', '8.5']

fail-fast: false

name: PHP ${{ matrix.php }} tests
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- run: composer install --no-progress --prefer-dist
- run: composer tester
- if: failure()
uses: actions/upload-artifact@v4
with:
name: output-${{ matrix.php }}
path: tests/**/output


lowest_dependencies:
name: Lowest Dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none

- run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable
- run: composer tester


code_coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none

- run: composer install --no-progress --prefer-dist
- run: composer tester -- -p phpdbg --coverage ./coverage.xml --coverage-src ./src
- run: wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
- env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: php php-coveralls.phar --verbose --config tests/.coveralls.yml
22 changes: 22 additions & 0 deletions bin/mcp-inspector
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

use Nette\McpInspector\ServerFactory;

// Find Composer autoloader
$autoloadPaths = [
__DIR__ . '/../vendor/autoload.php', // Standalone
__DIR__ . '/../../../autoload.php', // Installed as dependency
];

foreach ($autoloadPaths as $path) {
if (file_exists($path)) {
require $path;
break;
}
}

$server = ServerFactory::create();
$server->runCli();
53 changes: 53 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "nette/mcp-inspector",
"description": "🔭 MCP server for Nette application introspection",
"keywords": ["nette", "mcp", "model-context-protocol", "introspection", "di", "dependency-injection", "ai", "llm"],
"homepage": "https://nette.org",
"license": ["BSD-3-Clause", "GPL-2.0-only", "GPL-3.0-only"],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
}
],
"require": {
"php": "8.2 - 8.5",
"mcp/sdk": "^0.2",
"nette/di": "^3.2",
"nette/bootstrap": "^3.2",
"nette/neon": "^3.4",
"nyholm/psr7": "^1.8",
"nyholm/psr7-server": "^1.1"
},
"require-dev": {
"nette/application": "^3.2",
"nette/database": "^3.2",
"nette/routing": "^3.1",
"nette/tester": "^2.5.2",
"tracy/tracy": "^2.11",
"mockery/mockery": "^1.6@stable",
"phpstan/phpstan-nette": "^2.0@stable"
},
"autoload": {
"psr-4": {
"Nette\\": "src"
}
},
"bin": [
"bin/mcp-inspector"
],
"scripts": {
"phpstan": "phpstan analyse",
"tester": "tester tests -s -C"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
60 changes: 60 additions & 0 deletions license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Licenses
========

Good news! You may use Nette Framework under the terms of either
the New BSD License or the GNU General Public License (GPL) version 2 or 3.

The BSD License is recommended for most projects. It is easy to understand and it
places almost no restrictions on what you can do with the framework. If the GPL
fits better to your project, you can use the framework under this license.

You don't have to notify anyone which license you are using. You can freely
use Nette Framework in commercial projects as long as the copyright header
remains intact.

Please be advised that the name "Nette Framework" is a protected trademark and its
usage has some limitations. So please do not use word "Nette" in the name of your
project or top-level domain, and choose a name that stands on its own merits.
If your stuff is good, it will not take long to establish a reputation for yourselves.


New BSD License
---------------

Copyright (c) 2004, 2014 David Grudl (https://davidgrudl.com)
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of "Nette Framework" nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

This software is provided by the copyright holders and contributors "as is" and
any express or implied warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose are
disclaimed. In no event shall the copyright owner or contributors be liable for
any direct, indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or services;
loss of use, data, or profits; or business interruption) however caused and on
any theory of liability, whether in contract, strict liability, or tort
(including negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.


GNU General Public License
--------------------------

GPL licenses are very very long, so instead of including them here we offer
you URLs with full text:

- [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html)
- [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html)
126 changes: 126 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Nette MCP Inspector

MCP (Model Context Protocol) server for Nette application introspection. Allows AI assistants to inspect your Nette application's DI container, database schema, routing, and more.

<img width="2816" height="1406" alt="image" src="https://github.com/user-attachments/assets/35a314bb-065b-486f-8e58-972bdb45516c" />

## Installation

With [Claude Code](https://claude.com/product/claude-code) and the [Nette plugin](https://github.com/nette/claude-code):

```
/install-mcp-inspector
```

Or manually:

```bash
composer require nette/mcp-inspector
```

After installation, restart Claude Code session to activate the MCP server.

## Available Tools

### DI Container

| Tool | Description |
|------|-------------|
| `di_get_services` | List all registered services with types and autowiring info |
| `di_get_service` | Get details of a specific service (factory, setup calls, tags) |

### Database

| Tool | Description |
|------|-------------|
| `db_get_tables` | List all database tables |
| `db_get_columns` | Get columns of a specific table (types, nullable, primary key, foreign keys) |
| `db_get_relationships` | Get foreign key relationships between all tables (belongsTo, hasMany) |

### Router

| Tool | Description |
|------|-------------|
| `router_get_routes` | List all registered routes with masks and defaults |
| `router_match_url` | Match URL to presenter/action (e.g., "/article/123") |
| `router_generate_url` | Generate URL for presenter/action (e.g., "Article:show") |

## Configuration

Create `mcp-config.neon` in your project root (optional):

```neon
# Path to Bootstrap file (defaults to app/Bootstrap.php)
bootstrap: app/Bootstrap.php

# Bootstrap class name (defaults to App\Bootstrap)
bootstrapClass: App\Bootstrap

# Custom toolkits
toolkits:
- App\Mcp\MyCustomToolkit
```

## Creating Custom Toolkits

```php
use Mcp\Capability\Attribute\McpTool;
use Nette\McpInspector\Toolkit;
use Nette\McpInspector\Bridge\BootstrapBridge;

class MyToolkit implements Toolkit
{
public function __construct(
private BootstrapBridge $bridge,
) {}

/**
* Tool description from PHPDoc.
* @param string $param Parameter description
*/
#[McpTool(name: 'my_tool')]
public function myMethod(string $param): array
{
return ['result' => 'data'];
}
}
```

Register in `mcp-config.neon`:

```neon
toolkits:
- App\Mcp\MyToolkit
```

## Standalone Usage

### CLI Mode

```bash
php vendor/bin/mcp-inspector
```

### HTTP Mode

Copy `www/mcp-inspector.php` to your web root for HTTP-based MCP access.

### Manual MCP Configuration

If not using the Nette plugin, add to your project's `.mcp.json`:

```json
{
"mcpServers": {
"nette-inspector": {
"command": "php",
"args": ["vendor/bin/mcp-inspector"]
}
}
}
```

## Requirements

- PHP 8.2+
- Nette Framework 3.2+
Loading
Loading