Skip to content

Commit 6d21772

Browse files
authored
Merge branch 'develop' into dependabot/npm_and_yarn/webui/develop/nodemailer-8.0.4
2 parents b8faf84 + 613ab98 commit 6d21772

48 files changed

Lines changed: 3724 additions & 709 deletions

Some content is hidden

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

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ node_modules
2525
server/api/dashboard.go
2626
coverage.txt
2727
versioninfo.json
28+
.DS_Store
29+
Icon

.idea/workspace.xml

Lines changed: 644 additions & 640 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/handler.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
type Handler interface {
2323
http.Handler
2424
RegisterHealthHandler(path string, h http.Handler)
25+
RegisterMcpHandler(path string, h http.Handler)
2526
}
2627

2728
type handler struct {
@@ -33,6 +34,8 @@ type handler struct {
3334
index string
3435
healthPath string
3536
healthHandler http.Handler
37+
mcpPath string
38+
mcpHandler http.Handler
3639
}
3740

3841
type info struct {
@@ -111,6 +114,11 @@ func (h *handler) RegisterHealthHandler(path string, handler http.Handler) {
111114
h.healthHandler = handler
112115
}
113116

117+
func (h *handler) RegisterMcpHandler(path string, handler http.Handler) {
118+
h.mcpPath = path
119+
h.mcpHandler = handler
120+
}
121+
114122
func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
115123
if r.Method != "GET" && r.Method != "POST" {
116124
http.Error(w, fmt.Sprintf("method %v is not allowed", r.Method), http.StatusMethodNotAllowed)
@@ -154,6 +162,8 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
154162
h.getSearchResults(w, r)
155163
case strings.HasPrefix(p, h.healthPath) && h.healthHandler != nil:
156164
h.healthHandler.ServeHTTP(w, r)
165+
case strings.HasPrefix(p, h.mcpPath) && h.mcpHandler != nil:
166+
h.mcpHandler.ServeHTTP(w, r)
157167
case h.fileServer != nil:
158168
if r.Method != "GET" {
159169
http.Error(w, fmt.Sprintf("method %v is not allowed", r.Method), http.StatusMethodNotAllowed)

cmd/mokapi/main_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ health:
8989
path: /health
9090
port: 8080
9191
log: false
92+
mcp:
93+
server:
94+
enabled: false
95+
path: /mcp
96+
port: 8080
9297
rootCaCert: ""
9398
rootCaKey: ""
9499
configs: []

config/static/static_config.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Config struct {
1919
Providers Providers `json:"providers" yaml:"providers"`
2020
Api Api `json:"api" yaml:"api"`
2121
Health Health `json:"health" yaml:"health"`
22+
Mcp Mcp `json:"mcp" yaml:"mcp"`
2223
RootCaCert tls.FileOrContent `json:"rootCaCert" yaml:"rootCaCert" name:"root-ca-cert"`
2324
RootCaKey tls.FileOrContent `json:"rootCaKey" yaml:"rootCaKey" name:"root-ca-cert"`
2425
Configs Configs `json:"configs" yaml:"configs" explode:"config"`
@@ -44,6 +45,14 @@ func NewConfig() *Config {
4445
cfg.Health.Port = 8080
4546
cfg.Health.Path = "/health"
4647

48+
cfg.Mcp = Mcp{
49+
Server: McpServer{
50+
Enabled: false,
51+
Port: 8080,
52+
Path: "/mcp",
53+
},
54+
}
55+
4756
cfg.Providers.File.SkipPrefix = []string{"_"}
4857
cfg.Event.Store = map[string]Store{"default": {Size: 100}}
4958
cfg.DataGen.OptionalProperties = "0.85"
@@ -298,3 +307,13 @@ type Health struct {
298307
Port int `yaml:"port" json:"port"`
299308
Log bool `yaml:"log" json:"log"`
300309
}
310+
311+
type Mcp struct {
312+
Server McpServer `yaml:"server" json:"server"`
313+
}
314+
315+
type McpServer struct {
316+
Enabled bool `yaml:"enabled" json:"enabled"`
317+
Path string `yaml:"path" json:"path"`
318+
Port int `yaml:"port" json:"port"`
319+
}

docs/javascript-api/mokapi-http/fetchoptions.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ description: The FetchOptions object defines parameters for the fetch() function
77
The `FetchOptions` object defines additional parameters for the [`fetch()`](/docs/javascript-api/mokapi-http/fetch.md) function in the `mokapi/http` module.
88
It allows you to customize request behavior such as HTTP method, headers, body, timeout, and redirect handling.
99

10-
| Name | Type | Description |
11-
|--------------|----------------|--------------------------------------------------------------------------------------------------------------|
12-
| method | string | The HTTP method used for the request (e.g. `"GET"`, `"POST"`, `"PUT"`). Defaults to `"GET"`. | |
13-
| body | object | The request body to send. Automatically serialized to JSON when `Content-Type` is set to `application/json`. |
14-
| headers | object | Key-value pairs representing HTTP headers to include with the request. |
15-
| maxRedirects | number | The number of redirects to follow. Default value is 5. A value of 0 (zero) prevents all redirection. |
16-
| timeout | number, string | Maximum time to wait for the request to complete. Default timeout is 60 seconds ("60s") |
10+
| Name | Type | Description |
11+
|--------------|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
12+
| method | string | The HTTP method used for the request (e.g. `"GET"`, `"POST"`, `"PUT"`). Defaults to `"GET"`. | |
13+
| body | any | The request body to send. Automatically serialized to JSON when `Content-Type` is set to `application/json`. |
14+
| headers | object | Key-value pairs representing HTTP headers to include with the request. |
15+
| maxRedirects | number | The number of redirects to follow. Default value is 5. A value of 0 (zero) prevents all redirection. |
16+
| timeout | number, string | Maximum time to wait for the request to complete. Default timeout is 60 seconds ("60s") |
17+
| insecure | boolean | If set to true, TLS certificate verification is skipped. This allows connections to servers with self-signed or invalid certificates. Default is false. |
1718

1819
## Example of Accept header
1920

docs/javascript-api/mokapi-kafka/produceargs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ProduceArgs is an object used by [produce](/docs/javascript-api/mokapi-kafka/pro
1010
|-----------------------------------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1111
| cluster (optional) | string | Kafka cluster name. Used when topic name is not unique. |
1212
| topic (optional) | string | Kafka topic name. If not specified, message will be written to a random topic. |
13-
| messages | array | An list of [Message](/docs/javascript-api/mokapi-kafka/message.md) contains Kafka messages to produce into given topic |
13+
| messages | array | A list of [Message](/docs/javascript-api/mokapi-kafka/message.md) contains Kafka messages to produce into given topic |
1414
| partition (optional, deprecated ) | number | Kafka partition index. If not specified, the message will be written to any partition |
1515
| key (optional, deprecated) | any | Kafka message key. If not specified, a random key will be generated based on the topic configuration. |
1616
| value (optional, deprecated) | any | Kafka message value. If not specified, a random value will be generated based on the topic configuration. Object will be encoded based on the topic configuration |

docs/javascript-api/mokapi/eventhandler/kafkaeventmessage.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ description: KafkaEventMessage is an object used by KafkaEventHandler
77
KafkaMessage is an object used by [KafkaEventHandler](/docs/javascript-api/mokapi/eventhandler/kafkaeventhandler.md)
88
that contains Kafka-specific message data.
99

10-
| Name | Type | Description |
11-
|---------|--------|---------------------------------------------------------------|
12-
| offset | number | Kafka partition where the message was written to (read-only). |
13-
| key | string | Kafka message key |
14-
| value | string | Kafka message value |
15-
| headers | object | Kafka message headers |
10+
| Name | Type | Description |
11+
|---------|--------|------------------------------------------------|
12+
| offset | number | Kafka offset of the kafka message (read-only). |
13+
| key | string | Kafka message key |
14+
| value | string | Kafka message value |
15+
| headers | object | Kafka message headers |
1616

examples/swagger/streetlight.yaml

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
asyncapi: '2.6.0'
2+
info:
3+
title: Streetlights Kafka API
4+
version: '1.0.0'
5+
description: |
6+
The Smartylighting Streetlights API allows you to remotely manage the city lights.
7+
8+
### Check out its awesome features:
9+
10+
* Turn a specific streetlight on/off 🌃
11+
* Dim a specific streetlight 😎
12+
* Receive real-time information about environmental lighting conditions 📈
13+
license:
14+
name: Apache 2.0
15+
url: https://www.apache.org/licenses/LICENSE-2.0
16+
17+
servers:
18+
scram-connections:
19+
url: test.mykafkacluster.org:18092
20+
protocol: kafka-secure
21+
description: Test broker secured with scramSha256
22+
security:
23+
- saslScram: []
24+
tags:
25+
- name: "env:test-scram"
26+
description: "This environment is meant for running internal tests through scramSha256"
27+
- name: "kind:remote"
28+
description: "This server is a remote server. Not exposed by the application"
29+
- name: "visibility:private"
30+
description: "This resource is private and only available to certain users"
31+
mtls-connections:
32+
url: test.mykafkacluster.org:28092
33+
protocol: kafka-secure
34+
description: Test broker secured with X509
35+
security:
36+
- certs: []
37+
tags:
38+
- name: "env:test-mtls"
39+
description: "This environment is meant for running internal tests through mtls"
40+
- name: "kind:remote"
41+
description: "This server is a remote server. Not exposed by the application"
42+
- name: "visibility:private"
43+
description: "This resource is private and only available to certain users"
44+
45+
defaultContentType: application/json
46+
47+
channels:
48+
smartylighting.streetlights.1.0.event.{streetlightId}.lighting.measured:
49+
description: The topic on which measured values may be produced and consumed.
50+
parameters:
51+
streetlightId:
52+
$ref: '#/components/parameters/streetlightId'
53+
publish:
54+
summary: Inform about environmental lighting conditions of a particular streetlight.
55+
operationId: receiveLightMeasurement
56+
traits:
57+
- $ref: '#/components/operationTraits/kafka'
58+
message:
59+
$ref: '#/components/messages/lightMeasured'
60+
61+
smartylighting.streetlights.1.0.action.{streetlightId}.turn.on:
62+
parameters:
63+
streetlightId:
64+
$ref: '#/components/parameters/streetlightId'
65+
subscribe:
66+
operationId: turnOn
67+
traits:
68+
- $ref: '#/components/operationTraits/kafka'
69+
message:
70+
$ref: '#/components/messages/turnOnOff'
71+
72+
smartylighting.streetlights.1.0.action.{streetlightId}.turn.off:
73+
parameters:
74+
streetlightId:
75+
$ref: '#/components/parameters/streetlightId'
76+
subscribe:
77+
operationId: turnOff
78+
traits:
79+
- $ref: '#/components/operationTraits/kafka'
80+
message:
81+
$ref: '#/components/messages/turnOnOff'
82+
83+
smartylighting.streetlights.1.0.action.{streetlightId}.dim:
84+
parameters:
85+
streetlightId:
86+
$ref: '#/components/parameters/streetlightId'
87+
subscribe:
88+
operationId: dimLight
89+
traits:
90+
- $ref: '#/components/operationTraits/kafka'
91+
message:
92+
$ref: '#/components/messages/dimLight'
93+
94+
components:
95+
messages:
96+
lightMeasured:
97+
name: lightMeasured
98+
title: Light measured
99+
summary: Inform about environmental lighting conditions of a particular streetlight.
100+
contentType: application/json
101+
traits:
102+
- $ref: '#/components/messageTraits/commonHeaders'
103+
payload:
104+
$ref: "#/components/schemas/lightMeasuredPayload"
105+
turnOnOff:
106+
name: turnOnOff
107+
title: Turn on/off
108+
summary: Command a particular streetlight to turn the lights on or off.
109+
traits:
110+
- $ref: '#/components/messageTraits/commonHeaders'
111+
payload:
112+
$ref: "#/components/schemas/turnOnOffPayload"
113+
dimLight:
114+
name: dimLight
115+
title: Dim light
116+
summary: Command a particular streetlight to dim the lights.
117+
traits:
118+
- $ref: '#/components/messageTraits/commonHeaders'
119+
payload:
120+
$ref: "#/components/schemas/dimLightPayload"
121+
122+
schemas:
123+
lightMeasuredPayload:
124+
type: object
125+
properties:
126+
lumens:
127+
type: integer
128+
minimum: 0
129+
description: Light intensity measured in lumens.
130+
sentAt:
131+
$ref: "#/components/schemas/sentAt"
132+
turnOnOffPayload:
133+
type: object
134+
properties:
135+
command:
136+
type: string
137+
enum:
138+
- on
139+
- off
140+
description: Whether to turn on or off the light.
141+
sentAt:
142+
$ref: "#/components/schemas/sentAt"
143+
dimLightPayload:
144+
type: object
145+
properties:
146+
percentage:
147+
type: integer
148+
description: Percentage to which the light should be dimmed to.
149+
minimum: 0
150+
maximum: 100
151+
sentAt:
152+
$ref: "#/components/schemas/sentAt"
153+
sentAt:
154+
type: string
155+
format: date-time
156+
description: Date and time when the message was sent.
157+
158+
securitySchemes:
159+
saslScram:
160+
type: scramSha256
161+
description: Provide your username and password for SASL/SCRAM authentication
162+
certs:
163+
type: X509
164+
description: Download the certificate files from service provider
165+
166+
parameters:
167+
streetlightId:
168+
description: The ID of the streetlight.
169+
schema:
170+
type: string
171+
172+
messageTraits:
173+
commonHeaders:
174+
headers:
175+
type: object
176+
properties:
177+
my-app-header:
178+
type: integer
179+
minimum: 0
180+
maximum: 100
181+
182+
operationTraits:
183+
kafka:
184+
bindings:
185+
kafka:
186+
clientId:
187+
type: string
188+
enum: ['my-app-id']

go.mod

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ require (
6363
github.com/golang/snappy v0.0.4 // indirect
6464
github.com/google/go-github/v84 v84.0.0 // indirect
6565
github.com/google/go-querystring v1.2.0 // indirect
66+
github.com/google/jsonschema-go v0.4.2 // indirect
6667
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
6768
github.com/huandu/xstrings v1.3.2 // indirect
6869
github.com/imdario/mergo v0.3.14 // indirect
@@ -71,16 +72,21 @@ require (
7172
github.com/kevinburke/ssh_config v1.2.0 // indirect
7273
github.com/mitchellh/copystructure v1.0.0 // indirect
7374
github.com/mitchellh/reflectwalk v1.0.0 // indirect
75+
github.com/modelcontextprotocol/go-sdk v1.4.1 // indirect
7476
github.com/mschoch/smat v0.2.0 // indirect
7577
github.com/pjbgf/sha1cd v0.3.2 // indirect
7678
github.com/pmezard/go-difflib v1.0.0 // indirect
7779
github.com/robfig/cron/v3 v3.0.1 // indirect
80+
github.com/segmentio/asm v1.1.3 // indirect
81+
github.com/segmentio/encoding v0.5.4 // indirect
7882
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
7983
github.com/skeema/knownhosts v1.3.1 // indirect
8084
github.com/xanzy/ssh-agent v0.3.3 // indirect
85+
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
8186
go.etcd.io/bbolt v1.4.0 // indirect
8287
go.uber.org/atomic v1.9.0 // indirect
8388
golang.org/x/crypto v0.49.0 // indirect
89+
golang.org/x/oauth2 v0.34.0 // indirect
8490
golang.org/x/sys v0.42.0 // indirect
8591
google.golang.org/protobuf v1.36.6 // indirect
8692
gopkg.in/warnings.v0 v0.1.2 // indirect

0 commit comments

Comments
 (0)