Skip to content

Commit 5fc6d71

Browse files
committed
Init project
0 parents  commit 5fc6d71

File tree

123 files changed

+9197
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+9197
-0
lines changed

.gitignore

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Composer dependencies
2+
/vendor/
3+
/composer.lock
4+
5+
# PHPUnit
6+
.phpunit.result.cache
7+
8+
# PHP CS Fixer
9+
/.php-cs-fixer.cache
10+
11+
# Editor directories and files
12+
/.idea
13+
/.vscode
14+
*.sublime-project
15+
*.sublime-workspace
16+
17+
# Operating system files
18+
.DS_Store
19+
Thumbs.db
20+
21+
# Local environment files
22+
/.env
23+
/.env.backup
24+
/.env.local
25+
26+
# PHP CodeSniffer
27+
/.phpcs.xml
28+
/.phpcs.xml.dist
29+
/phpcs.xml
30+
/phpcs.xml.dist
31+
32+
# PHPStan
33+
/phpstan.neon
34+
/phpstan.neon.dist
35+
36+
# Local development tools
37+
/.php_cs
38+
/.php_cs.cache
39+
/.php_cs.dist
40+
/_ide_helper.php
41+
42+
# Build artifacts
43+
/.build/
44+
/coverage/
45+
46+
# PHPUnit coverage reports
47+
/clover.xml
48+
/coverage.xml
49+
/coverage/
50+
51+
# Laravel generated files
52+
bootstrap/cache/
53+
.phpunit.result.cache
54+
55+
# Local Composer dependencies
56+
composer.phar
57+
58+
workbench
59+
playground
60+
61+
# Log files
62+
*.log
63+
64+
# Cache files
65+
cache
66+
runtime
67+
68+
.context

.php-cs-fixer.dist.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
require_once 'vendor/autoload.php';
6+
7+
return \Spiral\CodeStyle\Builder::create()
8+
->include(__DIR__ . '/src')
9+
->include(__DIR__ . '/tests')
10+
->include(__FILE__)
11+
->build();

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Kyrian Obikwelu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Research module for CTX

composer.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"name": "ctx/mcp-server",
3+
"description": "MCP Server for CTX framework",
4+
"keywords": [],
5+
"type": "library",
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Pavel Buchnev",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"require": {
14+
"php": ">=8.3",
15+
"guzzlehttp/guzzle": "^7.0",
16+
"laminas/laminas-diactoros": "^3.5",
17+
"league/route": "^6.2",
18+
"logiscape/mcp-sdk-php": "^1.0",
19+
"psr-discovery/http-client-implementations": "^1.0",
20+
"psr-discovery/http-factory-implementations": "^1.0",
21+
"psr/http-client": "^1.0",
22+
"psr/http-factory": "^1.0",
23+
"spiral/boot": "^3.15",
24+
"spiral/config": "^3.15",
25+
"spiral/console": "^3.15",
26+
"spiral/files": "^3.15",
27+
"spiral/json-schema-generator": "^2.1",
28+
"cuyz/valinor": "^1.7"
29+
},
30+
"require-dev": {
31+
"spiral/code-style": "^2.2",
32+
"phpunit/phpunit": "^10.5",
33+
"rector/rector": "^2.1",
34+
"vimeo/psalm": "^6.0"
35+
},
36+
"autoload": {
37+
"psr-4": {
38+
"Butschster\\ContextGenerator\\McpServer\\": "src/"
39+
}
40+
},
41+
"autoload-dev": {
42+
"psr-4": {
43+
"Tests\\": "tests"
44+
}
45+
},
46+
"scripts": {
47+
"cs-check": "vendor/bin/php-cs-fixer fix --dry-run",
48+
"cs-fix": "vendor/bin/php-cs-fixer fix",
49+
"psalm": "vendor/bin/psalm --config=psalm.xml ./src",
50+
"psalm:ci": "vendor/bin/psalm --config=psalm.xml ./src --output-format=github --shepherd --show-info=false --stats --threads=4 --no-cache",
51+
"refactor": "rector process --config=rector.php",
52+
"refactor:ci": "rector process --config=rector.php --dry-run --ansi",
53+
"test": "vendor/bin/phpunit",
54+
"test:cc": [
55+
"@putenv XDEBUG_MODE=coverage",
56+
"phpunit --coverage-clover=.build/phpunit/logs/clover.xml --color=always"
57+
],
58+
"cs:fix": [
59+
"@cs-fix",
60+
"@refactor"
61+
],
62+
"lint": [
63+
"@cs-check",
64+
"@refactor:ci",
65+
"@psalm",
66+
"@test"
67+
]
68+
},
69+
"config": {
70+
"sort-packages": true
71+
},
72+
"minimum-stability": "dev",
73+
"prefer-stable": true
74+
}

phpunit.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
>
7+
<testsuites>
8+
<testsuite name="Test Suite">
9+
<directory suffix="Test.php">./tests</directory>
10+
</testsuite>
11+
</testsuites>
12+
<source>
13+
<include>
14+
<directory>src</directory>
15+
</include>
16+
</source>
17+
</phpunit>

psalm.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="4"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
findUnusedBaselineEntry="true"
9+
findUnusedCode="false"
10+
findUnusedVariablesAndParams="true"
11+
ensureOverrideAttribute="false"
12+
>
13+
<projectFiles>
14+
<directory name="src"/>
15+
<ignoreFiles>
16+
<directory name="vendor"/>
17+
<directory name="tests"/>
18+
</ignoreFiles>
19+
</projectFiles>
20+
</psalm>

rector.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
7+
use Rector\Set\ValueObject\LevelSetList;
8+
use Rector\Set\ValueObject\SetList;
9+
10+
return static function (RectorConfig $rectorConfig): void {
11+
$rectorConfig->paths([
12+
__DIR__ . '/src',
13+
__DIR__ . '/tests',
14+
]);
15+
16+
// Register rules for PHP 8.4 migration
17+
$rectorConfig->sets([
18+
SetList::PHP_83,
19+
LevelSetList::UP_TO_PHP_83,
20+
]);
21+
22+
// Skip vendor directories
23+
$rectorConfig->skip([
24+
__DIR__ . '/vendor',
25+
AddOverrideAttributeToOverriddenMethodsRector::class,
26+
]);
27+
};

src/Action/ToolResult.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Butschster\ContextGenerator\McpServer\Action;
6+
7+
use Mcp\Types\CallToolResult;
8+
use Mcp\Types\TextContent;
9+
10+
/**
11+
* Helper class to simplify creating CallToolResult instances for MCP tool actions.
12+
*/
13+
final class ToolResult
14+
{
15+
/**
16+
* Create a successful tool result with data.
17+
*/
18+
public static function success(array|\JsonSerializable $data): CallToolResult
19+
{
20+
return new CallToolResult([
21+
new TextContent(
22+
text: \json_encode($data),
23+
),
24+
]);
25+
}
26+
27+
/**
28+
* Create an error tool result with an error message.
29+
*/
30+
public static function error(string $error): CallToolResult
31+
{
32+
return new CallToolResult([
33+
new TextContent(
34+
text: \json_encode([
35+
'success' => false,
36+
'error' => $error,
37+
]),
38+
),
39+
], isError: true);
40+
}
41+
42+
/**
43+
* Create an error tool result with validation details.
44+
*/
45+
public static function validationError(array $validationErrors): CallToolResult
46+
{
47+
return new CallToolResult([
48+
new TextContent(
49+
text: \json_encode([
50+
'success' => false,
51+
'error' => 'Validation failed',
52+
'details' => $validationErrors,
53+
]),
54+
),
55+
], isError: true);
56+
}
57+
58+
/**
59+
* Create a simple text result (for cases where just text is returned).
60+
*/
61+
public static function text(string $text): CallToolResult
62+
{
63+
return new CallToolResult([
64+
new TextContent(
65+
text: $text,
66+
),
67+
]);
68+
}
69+
}

src/Attribute/InputSchema.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Butschster\ContextGenerator\McpServer\Attribute;
6+
7+
#[\Attribute(\Attribute::TARGET_CLASS)]
8+
final readonly class InputSchema
9+
{
10+
/**
11+
* @param class-string $class
12+
*/
13+
public function __construct(
14+
public string $class,
15+
) {}
16+
}

0 commit comments

Comments
 (0)